我有一个windows2003服务器(WINJOE),我想备份到一个Linux机器(LINUXJOE),正确地join到域的Windows共享。 我的目标是将WINJOE的共享文件夹备份到LINUXJOE,同时保持Windows的权限/所有者。 在阅读相关文献后,我觉得这是不可能的…
无论如何,在一个理想的世界中,我想在LINUXJOE上挂载一个win共享(只读),例如\\ WINJOE \ important_folder,并从那里运行rsync到备份目录。
我到目前为止:
\ WINJOE \ important_folder – >共享文件夹进行备份
LINUXJOE:/ mnt / important – >在LINUXJOE上挂载\\ WINJOE \ important_folder
LINUXJOE:/ backup / $ DATE-important – >备份目标目录
目前,我能够使用我的Windows域帐户login到LINUXJOE,如果我在LINUXJOE的文件系统上创build文件,它们将所有者显示为“somewinuser”域用户“”,因此从Windows到Linux的用户映射工作正常。 当我使用以下命令安装\\ WINJOE \ important_folder时:
linuxjoe# mount.cifs //WINJOE/important_folder /mnt/important \ -o ro,user=backitup,dom=TODOMAIN,cifsacl,nounix --verbose
我得到:
ls -latrh linuxjoe# ls -latrh /mnt/important total 518M -r-xr-xr-x 0 root root 518M Sep 28 01:19 test.mkv -rwxr-xr-x 0 root root 0 Oct 25 19:04 testlalala -rwxr-xr-x 0 root root 0 Oct 25 19:05 testkoko drwxrwxrwx 1 root domain users 0 Oct 25 19:05 . drwxr-xr-x 5 root root 4.0K Oct 29 16:29 .. getcifsacl linuxjoe# getcifsacl /mnt/important/test.mkv REVISION:0x1 CONTROL:0x8404 OWNER:BUILTIN\Administrators GROUP:TODOMAIN\Domain Users ACL:Everyone:ALLOWED/I/FULL ACL:NT AUTHORITY\SYSTEM:ALLOWED/I/FULL ACL:BUILTIN\Administrators:ALLOWED/I/FULL ACL:TODOMAIN\lukeskywalker:ALLOWED/I/FULL rsyncing: linuxjoe# rsync -apvXAgo /mnt/important/koko.mkv /root/test/ linuxjoe# ls -latrh /root/test/ total 518M -rwxrwxrwx 1 root domain users 518M Sep 28 01:19 test.mkv drwx------ 8 root root 4.0K Oct 29 18:29 .. drwxr-xr-x 2 root root 4.0K Oct 29 18:29 .
是否有可能,在Windows共享上查看文件的正确拥有者,并保持该所有者以及所有Windows安全属性,当我的rsync从Windows共享到我的Linux备份盒?
smb.conf文件
[global] workgroup = TODOMAIN realm=SOMEOFFICE.SOMEWHERE.GR server string = %h server wins support = no security = ads encrypt passwords = yes obey pam restrictions = yes template shell = /bin/bash template homedir = /home/%D/%U password server=winjoe.someoffice.somewhere.gr domain master = no local master = no prefered master = no idmap config * : backend = rid idmap config * : range = 5000-3000000000 idmap config * : base_rid = 0 idmap config TODOMAIN : backend = rid idmap config TODOMAIN : range = 5000-3000000000 idmap cache time = 900 algorithmic rid base = 5000 client schannel = no disable spoolss=yes winbind separator=+ winbind use default domain=yes winbind nested groups=yes winbind enum users=yes winbind enum groups=yes winbind cache time= 300 winbind refresh tickets = yes inherit acls = Yes map acl inherit = Yes acl group control = yes
不幸的是,Linux ACL和Windows ACL非常不同。 当您通过Samba从Windows访问Linux文件系统时,Samba设法将简单的Linux ACL映射到Windows ACL,而不会丢失太多信息。 为了这个工作,你已经需要你在smb.conf中的许多选项。
相反,更困难的甚至是不可能的,尤其是Linux挂载与Windows映射共享具有不同的语义。 而安装发生在内核驱动程序根本不实现ACL。 我们唯一的办法是用getcifsacl等附加程序获取信息。
所以像rsync这样普通的Linux工具对Windows ACL并不了解,不能存储它们。 如果您需要恢复这些ACL,则需要使用getcifsacl自己保存并使用setcifsacl进行恢复。 由于这些命令只能处理单个文件,而setcifsacl不能直接处理getcifsacl的输出,所以需要一套复杂的脚本来备份/恢复这些ACL。 快速search没有显示任何现有的解决scheme。
解决这个问题的方法之一是让Windows进行备份,并使用Linux共享作为备份文件(而不是单个文件)的存储。
如何在samba目录中创build大文件并将其挂载为循环? 这是如何工作,基于伟大的文章http://users.softlab.ntua.gr/~ttsiod/backup.html
dd if=/dev/zero of=/mnt/windows/BigFile bs=1M count=1 seek=150000 mount.cifs //WINJOE/important_folder /mnt/important \ -o lfs,user=backitup,dom=TODOMAIN,cifsacl,nounix --verbose
默认情况下,Samba安装的文件大小限制为2GB(或4GB,不确定)。 这就是为什么在安装中使用“ lfs ”选项,以允许更大的文件。
mount -o loop /mnt/important/BigFile /mnt/backup losetup /dev/loop0 /mnt/windows/BigFile
可选地使用encryption: losetup -e aes256
mkfs.ext4 /dev/loop0 mount /dev/loop0 /mnt/important/BigFile cd /mnt/important/BigFile rsync -avz --exclude /proc --exclude /sys root@server:/ ./