使用rsync备份文件

为了避免丢失宝贵的劳动成果,建议大家养成经常备份文件的好习惯。幽兰具有512G的SSD空间,可以轻松满足大家的日常备份需求。下面是使用rsync命令进行备份的基本步骤。

  1. 在SSD上创建备份目录
    mkdir /gewu/homebak
    如果你还没有挂载SSD,那么请参考https://www.nanocode.cn/wiki/docs/youlan/jion05
    如果是以sudo命令创建的目录,那么执行如下命令将目录的所用权交给geduer用户:
    sudo chown -R geduer /gewu/homebak

  2. 以备份home目录为例,执行如下rsync命令:

    cd ~
    rsync -avxP . /gewu/homebak

如果要备份其它目录,只要把.换为要备份的目录名。选项中的avxP含义如下:
-a means archive mode
-v means print out the verbose information during backuping
-x means not cross filesystem boundaries
-P is shortcut for
–progress means printing information showing the progress of the transfer
–partial means keeping partially transferred files if the transfer is interrupted

上述命令发出后,rsync便开始备份了。备份结束时,会显示出类似下面这样的简单报告:

sent 2,760,166,466 bytes received 632,309 bytes 60,676,896.15 bytes/sec
total size is 2,757,165,226 speedup is 1.00

作者:沈根成  创建时间:2023-08-07 16:30
最后编辑:zuoyingying  更新时间:2024-05-06 17:42