Linux中rsync备份数据使用实例

rsync工具用于将文件和目录从一个位置同步到另一个位置。同步的位置可以在本地服务器或远程服务器上。 在Centos中使用下面命令安装rsync:[root@localhost ~]# yum -y install rsync实例一:本机中的两个目录进行同步要同步本地计算机中的两个目录,使用rsync -zvr命令:[root@localhost ~]# rsync -zvr /var/log/ /root/temp/sending incremental file listb
摘要由CSDN通过智能技术生成
rsync工具用于将文件和目录从一个位置同步到另一个位置。同步的位置可以在本地服务器或远程服务器上。

Centos中使用下面命令安装rsync:

[root@localhost ~]# yum -y install rsync

实例一:本机中的两个目录进行同步

要同步本地计算机中的两个目录,使用rsync -zvr命令

[root@localhost ~]# rsync -zvr /var/log/ /root/temp/
sending incremental file list
btmp
dnf.librepo.log
...
sssd/sssd_implicit_files.log
sssd/sssd_nss.log
tuned/tuned.log

sent 516,136 bytes  received 605 bytes  1,033,482.00 bytes/sec
total size is 5,451,242  speedup is 10.55

参数解释:

  • -z 启用压缩
  • -v 输出详细信息
  • -r 表示递归

查看一下/root/temp目录,发现rsync在同步期间未保留时间戳。

Linux中rsync备份数据使用实例Linux中rsync备份数据使用实例

实例二:使用rsync -a在同步期间保留时间戳

rsync命令的-a选项表示存档模式。-a选项递归同步、保留符号链接、保留权限、保留时间戳、保留所有者和组。

现在,执行以下命令,然后查看文件的时间:

[root@localhost ~]# rsync -azv /var/log/ /root/temp/
sending incremental file list
./
btmp
dnf.librepo.log
dnf.log
dnf.rpm.log
...
sssd/sssd_nss.log
tuned/
tuned/tuned.log

sent 516,231 bytes  received 629 bytes  1,033,720.00 bytes/sec
total size is 5,451,789  speedup is 10.55

如下所示,rsync在同步期间保留了时间戳。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值