大家好我的服务器Linux与Ubuntu10在etc / crontab我有这样的:
0 0 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server1/www 0 1 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server2/www 0 2 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server3/www
服务器有一个2TB的硬盘,例如我的备份我已经占用了1TB左右。
我每天晚上做了备份,现在如果一年以上这个备份工作我的硬盘的空间我认为减less是因为rdiff-backup创build了更改文件的历史logging。
有可能限制到我的crontab限制历史和mantain控制硬盘的空间? 就像:“30版后取消最古老”。
有可能做到我的文件crontab?
由于您的cron作业每天都在运行,并且您希望保留30个版本,所以这与删除30天以前的所有增量备份相同。
这可以通过使用指定30D或1M的--remove-older-than选项进行rdiff-backup来实现。 您不能将--remove-older-than与在单个命令中备份或恢复数据相结合。 你将需要添加行到你的crontab。
另一个需要注意的是--remove-older-than拒绝同时删除多个增量,除非你指定--force选项。 您可以尝试使用--force手动运行一次,然后让cron作业每天删除一个增量。 如果cron作业因为任何原因(例如服务器closures)而不运行,可能会造成麻烦。 我将在cron作业中包含--force选项。
你的新的crontab可能看起来像这样:
0 0 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server1/www 0 1 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server2/www 0 2 * * * user rdiff-backup -v9 [email protected]::/var/www/ /mnt/server3/www 0 3 * * * user rdiff-backup -v9 --remove-older-than 1M --force /mnt/server1/www 20 3 * * * user rdiff-backup -v9 --remove-older-than 1M --force /mnt/server2/www 40 3 * * * user rdiff-backup -v9 --remove-older-than 1M --force /mnt/server3/www
无论是在创build新备份之前删除旧增量,还是在什么时候运行哪个作业都是您应该决定的。
要清楚:只有在30天之前恢复到增量备份状态所需的信息将被删除,而不是现在仍然存在的旧数据,或者在最近的增量备份中。
有关--remove-older-than选项的更多信息,您可以阅读手册页 :
--remove-older-than time_spec Remove the incremental backup information in the destination directory that has been around longer than the given time. time_spec can be either an absolute time, like "2002-01-04", or a time interval. The time interval is an integer followed by the character s, m, h, D, W, M, or Y, indicating seconds, min- utes, hours, days, weeks, months, or years respectively, or a number of these concatenated. For example, 32m means 32 min- utes, and 3W2D10h7s means 3 weeks, 2 days, 10 hours, and 7 sec- onds. In this context, a month means 30 days, a year is 365 days, and a day is always 86400 seconds. rdiff-backup cannot remove-older-than and back up or restore in a single session. In order to both backup a directory and remove old files in it, you must run rdiff-backup twice. By default, rdiff-backup will only delete information from one session at a time. To remove two or more sessions at the same time, supply the --force option (rdiff-backup will tell you if --force is required). Note that snapshots of deleted files are covered by this opera- tion. Thus if you deleted a file two weeks ago, backed up imme- diately afterwards, and then ran rdiff-backup with --remove- older-than 10D today, no trace of that file would remain. Finally, file selection options such as --include and --exclude don't affect --remove-older-than.
你可以试试
rdiff-backup --remove-older-than 1M /mnt/server1/www
您需要添加另一行到您的crontab告诉rdiff备份删除文件。
从http://www.nongnu.org/rdiff-backup/examples.html :
本节假定过去使用rdiff-backup备份到host.net::/remote-dir,但是如果省略主机名,则所有命令也可以在本地工作。
这个命令删除所有有关文件版本的信息,这两个文件版本在2周内还没有被使用:
rdiff-backup –remove-older-than 2W host.net::/remote-dir请注意,一年中未更改的现有文件仍将保留。 但运行此命令后,15天前删除的文件无法恢复。 当恢复时,有多种方式来指定时间。 下面的20B告诉rdiff-backup只保留最近20次rdiff备份会话的信息。 (nnB语法仅在0.13.1之后的版本中可用)。
rdiff-backup –remove-older-than 20B host.net::/remote-dir