[daily][archlinux][rsync] rsync

 

科普文档:https://wiki.archlinux.org/index.php/Rsync

之前改文件系统时,用过。 然而用的不太对,导致一部分文件的权限出了问题。

[troubleshoot][archlinux][bcache] 修改linux文件系统 / 分区方案 / 做混合硬盘 / 系统转生大!手!术!(调整底层架构,不!重!装!)

使用rsync做全系统备份的教程:https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync

 

一,在备份server上启动 rsync服务。当然不启动也行,因为可以使用ssh。

man rsyncd.conf

  高不太清楚怎么用,好像也没有必要配。直接ssh。

二,通过ssh使用rsync,参考

  还参考了仙子的 旧文章

/home/tong [tong@T7] [11:44]
> sudo pacman -S rsync

 

三, 写了个脚本,来使用。

/home/tong [tong@T7] [19:07]
> cat bin/rsync-t7
#! /usr/bin/bash
 
cd $(dirname $0)

if [[ $# -lt 0 || $# -gt 1 ]]; then
        echo "usage: $0 [-w]"
        exit 1
fi

src=/
dest=tong@192.168.10.50:/home/tong/Data/Bak/T7-rsync/ROOT_FS
doit=$1
 
if [[ $doit == -w ]]; then
        dry=
else
        dry='-n'
fi
 
sudo rsync --archive --acls --xattrs --numeric-ids\
        --delete \
        --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
        --sparse \
        --hard-links \
        --human-readable --itemize-changes --progress \
        --verbose \
   -M--fake-super \ $src $dest $dry #
--delete-excluded # --one-file-system \

 

其中: --one-file-system  会导致单独挂在的/home分区和/boot分区不能被同步。

-----------  update @ 20170701 --------------

以上的脚步在实际使用中,发现了一个问题。

T7使用的是root用户,Tstation(192.168.10.50)使用的tong用户登录。这样的话,实际上就丢失了文件的所有者信息。

可以在远端-M增加--fake-super命令来解决这一问题。 

然后从远端(Tstation)同步回来(T7)的时候,使用相同的命令即可。

详细参见 man rsync  fake-super章节。

 

-----------  update @ 20180531 ----------

在本地sync的时候,-M--fake-super会导致软连接copy之后变成文件。原因不清楚。

[root@nlbtest tong]# rsync --archive --acls --xattrs --numeric-ids --delete --sparse --hard-links --human-readable --itemize-changes -M--fake-super ./src/ ./dst
.d..t.....x ./
cL+++++++++ bin -> usr/bin/
.d........x usr/
.d........x usr/bin/
[root@nlbtest tong]# ll dst/
total 12
-rwxrwxrwx. 1 root root  8 May 31 13:52 bin
drwxr-xr-x. 3 root root 16 May 31 13:52 usr
[root@nlbtest tong]# 

 

posted on 2017-06-11 11:24  toong  阅读(434)  评论(0编辑  收藏  举报