Backup Script weird tar message

Preston Hagar prestonh at gmail.com
Tue May 27 21:12:02 UTC 2008


On Sun, Feb 3, 2008 at 1:38 PM, Dubh Aingeal <ubuntu at dubh-aingeal.com> wrote:
> So I am working on a shell script to do a incremental backups. The
> script basically makes a full monthly backup then once a week makes
> another full back up with daily incremental backups. To limit the
> storage amount of backups, the script rewrites the weekly/daily backups.


As a somewhat side note (I think others have somewhat addressed your
question), I would highly recommend looking into hard links:

http://www.mikerubel.org/computers/rsync_snapshots/#Incremental

It is the way I have done incremental backups for a while and it is
great.  Basically, the idea is that when you do daily (or weekly)
snapshots of a directory, you only make new copies of the files that
have changed.  The files that are the same for the previous day's
snapshot are just hard linked.  This basically just puts another
pointer to a file, instead of making two copies (and taking up more
space)

As an example of the space savings, one client I currently use this
method for (I use it a lot, including for my own backups) keeps 30
days of snapshots on a USB drive.  One full day's backup uses 107 GB
of space, while all 30 days worth of backups are only using a total of
132 GB because there is only one copy of each version of each file.
Here is the backup script I use that might help out:

#!/bin/sh
exec > /var/log/hd_backup.log

echo "*****Backup Started: " `date`

# perform 30 days worth of snapshots.  Add or remove
# mv lines to increase or decrease the number of snapshots
cd /mnt/ext_backup
rm -rf 30
mv 29 30
mv 28 29
mv 27 28
mv 26 27
mv 25 26
mv 24 25
mv 23 24
mv 22 23
mv 21 22
mv 20 21
mv 19 20
mv 18 19
mv 17 18
mv 16 17
mv 15 16
mv 14 15
mv 13 14
mv 12 13
mv 11 12
mv 10 11
mv 9 10
mv 8 9
mv 7 8
mv 6 7
mv 5 6
mv 4 5
mv 3 4
mv 2 3
mv 1 2

cp -al /mnt/ext_backup/current /mnt/ext_backup/1

# Touch the files to put a timestamp on the directory of the date that
# it was backed up.
touch /mnt/ext_backup/current
touch -r /mnt/ext_backup/current /mnt/ext_backup/1

# The two directories I backup on the system are /home and /etc
# The USB hard drive that the backup is copied to is mounted at
# /mnt/ext_backup

rsync -Crav  --delete /home/ /mnt/ext_backup/current/data
rsync -Crav  --delete /etc/ /mnt/ext_backup/current/etc

date=$(date +%Y-%m-%d)
echo "*****Backup Completed: " `date`

# END SCRIPT


Preston




More information about the ubuntu-users mailing list