首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >优化空间选择-备份

优化空间选择-备份
EN

Server Fault用户
提问于 2013-03-26 08:07:25
回答 3查看 5K关注 0票数 2

嗨,在我的服务器linux中使用了etc/crontab中的Ubuntu10,我有以下内容:

代码语言:javascript
复制
0 0 * * * user rdiff-backup -v9 user@111.111.111.111::/var/www/ /mnt/server1/www
0 1 * * * user rdiff-backup -v9 user@222.222.222.222::/var/www/ /mnt/server2/www
0 2 * * * user rdiff-backup -v9 user@333.333.333.333::/var/www/ /mnt/server3/www

例如,服务器有一个2Tb的硬盘,我的备份占用了1Tb。

我每天晚上都做备份,现在如果这个备份工作一年或更长时间,我认为我的硬盘空间会减少,因为rdiff备份记录了更改的文件。

是否可以限制进入我的crontab来限制历史和控制硬盘的空间?大概是这样的:“30岁后取消最老的”。

可以在我的文件crontab中完成吗?

EN

回答 3

Server Fault用户

回答已采纳

发布于 2013-04-03 08:05:52

因为您的cron作业每天运行,并且您希望保留30个版本,这与删除所有超过30天的增量备份是一样的。

使用--remove-older-than选项(指定30D1M )进行rdiff备份是可能的。不能将--remove-older-than与单个命令中的数据备份或还原结合起来。您需要在crontab中添加行。

另一个警告是--remove-older-than拒绝同时删除多个增量,除非您指定了--force选项。您可以尝试使用--force手动运行一次,然后让cron作业每天删除一次增量。如果cron作业不以任何理由运行(例如服务器停机),这可能会造成麻烦。我将在cron作业中包括--force选项。

您的新crontab看起来可能如下所示:

代码语言:javascript
复制
0 0 * * * user rdiff-backup -v9 user@111.111.111.111::/var/www/ /mnt/server1/www
0 1 * * * user rdiff-backup -v9 user@222.222.222.222::/var/www/ /mnt/server2/www
0 2 * * * user rdiff-backup -v9 user@333.333.333.333::/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

是否在创建新备份之前删除旧的增量,或者在什么时候运行哪个作业是您应该决定的事情。

需要明确的是:只有在30天之前恢复到增量备份状态所需的信息才会被删除,而不是现在仍然存在的旧数据,或者是最近的增量备份。

有关--remove-older-than选项的更多信息,您可以阅读手册页

代码语言:javascript
复制
--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.
票数 5
EN

Server Fault用户

发布于 2013-03-26 08:43:25

你可以试试

代码语言:javascript
复制
rdiff-backup --remove-older-than 1M /mnt/server1/www
票数 1
EN

Server Fault用户

发布于 2013-03-30 10:47:07

您需要在crontab中添加另一行,以告诉rdiff备份以删除文件。

来自http://www.nongnu.org/rdiff-backup/examples.html

本节假设rdiff备份过去曾用于备份host.net::/remote dir,但如果主机名被省略,所有命令也将在本地工作。此命令删除所有有关文件版本的信息,这些文件版本已经有两个星期没有更新了:rdiff-备份-删除-旧的2W主机::/远程-dir注意,一个已经一年没有改变的现有文件仍将被保存。但是,在运行此命令后,无法还原15天前删除的文件。与恢复时一样,有多种方法来指定时间。下面的20B告诉rdiff备份只保留前20个rdiff备份会话中的信息。(nnB语法仅在0.13.1之后的版本中可用。)rdiff-备份-删除-早于20B主机.dir::/remote dir

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/491341

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档