rsync远程备份打包目录_如何使用rsync备份Linux Home目录

本文介绍了如何使用rsync工具快速备份Linux主目录到外部硬盘。由于git不支持大文件,作者转向了rsync,它能进行增量备份并保持高效。通过执行特定命令,可以实现备份,并可通过cron定时执行。此方法适用于具有足够权限的任何目录备份。
摘要由CSDN通过智能技术生成

rsync远程备份打包目录

I need to backup my Linux home directory to one of my portable hard disk. I tried to use git, but failed since git doesn’t support large file (I failed after many tries, I have file larger than 5G). I find rsync, the fast, versatile, remote (and local) file-copying tool and I am happy with it now. rsync is very fast especially the change is incremental. rsync can generate a delta of the change.

我需要将Linux主目录备份到我的便携式硬盘之一。 我尝试使用git,但由于git不支持大文件而失败(经过多次尝试后失败,我的文件大于5G)。 我发现rsync是一种快速,多功能,远程(和本地)文件复制工具,我现在对此感到满意。 rsync非常快,尤其是增量更改。 rsync可以生成更改的增量。

The method is simple, just execute this command:

方法很简单,只需执行以下命令:

$ rsync -avxP \
/path/to/directory/to/backup \
/path/to/directory/for/storing/backup
-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

Note that the files on the destination directory storing the backup data will be kept if the files do not exist in the source directory to be backup’ed. If you would like rsync to delete the files/directories in the destination directory if the files/directories does not exist in the source directory, you can add --delete to rsync:

请注意,如果要备份的源目录中不存在文件,则将保留目标目录中存储备份数据的文件。 如果您希望rsync在源目录中不存在文件/目录的情况下删除目标目录中的文件/目录,则可以在rsync添加--delete

$ rsync -avxP --delete \
/path/to/directory/to/backup \
/path/to/directory/for/storing/backup

You can check all options of rsync from rsync’s man page.

您可以从rsync的手册页中检查rsync的所有选项。

That’s it. You can use cron to run it every day or every week.

而已。 您可以每天或每周使用cron运行它。

The method can also be used to backup other kinds of directories besides of linux home directories given the user running rsync has sufficient permission to the directories and files. rsync also supports copying files to remote host. Please check “man rsync” for more.

如果运行rsync的用户对目录和文件具有足够的权限,则该方法还可以用于备份Linux主目录以外的其他类型的目录。 rsync还支持将文件复制到远程主机。 请检查“ man rsync”以获取更多信息。

翻译自: https://www.systutorials.com/backup-linux-home-directory-using-rsync/

rsync远程备份打包目录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值