需要某种软件(Debian)来创建备份。通常有几个文件夹,包含约 10k 个文件,总 zip 大小约 5Gb。最多需要创建 7 个备份。即 - 每天删除最旧的备份。
即需要包含 7 个yyyy-mm-dd.tar.gz
文件和最后存档的文件夹。我确定存在某种标准控制台软件可以自动执行此操作吗?
答案1
正如您所说,肯定有很多标准软件可以做到这一点。目前,我正在使用自建的 shell 脚本来实现此目的。将来,我会将其迁移到 Perl,以便在仪表板上显示成功和失败。我已经为六台服务器的 MySQL 备份实现了类似的概念,它们在 Amazon SimpleDB 中更新状态,我有一个仪表板来检查状态。
这是我的脚本:
#!/bin/sh
HOSTNAME=MYHOSTNAME # name of this computer
DIRECTORIES="/var/www /etc/ /var/backup/database" # directories to backup
BACKUPDIR=/mnt/backup # where to store the backups
TIMEDIR=/mnt/backup/last-full # where to store time of full backup
TAR=/bin/tar # name and location of tar
PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b%Y` # Date and Month e.g. 27Sep2010
# On the 6 of the month a permanent full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last week incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets its date from the file written every Sunday.
# Monthly full backup
if [ $DOM = "06" ]; then
NEWER=""
$TAR $NEWER -cf $BACKUPDIR/$HOSTNAME-$DM.tar $DIRECTORIES
fi
# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`
# Update full backup date
echo $NOW > $TIMEDIR/$HOSTNAME-full-date
$TAR $NEWER -cf $BACKUPDIR/$HOSTNAME-$DOW.tar $DIRECTORIES
# Make incremental backup - overwrite last weeks
else
# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$HOSTNAME-full-date`"
$TAR $NEWER -cf $BACKUPDIR/$HOSTNAME-$DOW.tar $DIRECTORIES
fi
答案2
答案3
我非常喜欢基于硬链接的完整备份,因为在大多数应用程序中,它们仅比增量备份占用一点点空间,但仍然提供完整备份的全部功能。
一个自动化基于硬链接的备份的工具是快照,它基于 rsync。您也可以直接使用rsync
开关--link-dest
来启用对未更改文件的先前备份的链接。但是 rsnapshot 为您提供了所有元功能(保留 n 个备份、删除旧备份等)。