Trace: » using_tar

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

You don't have an account yet? Just get one: Register

Forgotten your password? Get a new one: Send new password

tar

Creating

tar -cvf mystuff.tar mystuff/
tar -czvf mystuff.tgz mystuff/

Extracting

tar -xvf mystuff.tar
tar -xzvf mystuff.tgz

Automating the process

Put the full script in /etc/cron.weekly and the incremental script in /etc/cron.daily.

In tar, incremental backups need to be told which files to look at. In the full script we’re writing todays date to a file (which must exist already) before running the backup job. The incremental script reads from that same file and passes the date to the tar command so that it knows when the last full backup was. This way, we only ever have to renew 1x incremental and 1x full backup to get back to the last state. (at the expense of our incremental backups being a bit on the large side).

Everything created in the last couple of days is backed up.

fullbackup.sh

#!/bin/sh
#Backup /var/www to mounted network location /media/netbackup - full backup
#record the date of the full last backup
date +%d%b > /media/netbackup/lastfullbackupdate
#run full backup command
tar cpf /media/netbackup/fullbackup-`date '+%d-%B-%Y'`.tar /var/www

incrementalbackup.sh

<code>#!/bin/sh #Incremental backup #Get the date of the last full backup NEWER=”–newer `cat /media/netbackup/lastfulldatebackup`” #And run an incremental tar $NEWER -cf /media/netbackup/incremental`date +%a`.tar /var/www </code>

#!/bin/sh
tar -cf /media/netbackup/incremental`date +%a`.tar --after-date='2 days ago' /var/www