backup script

Alan Jackson ajackson
Mon May 17 11:57:27 PDT 2004


On Fri, 26 Dec 2003 16:52:36 -0800
Marianne Taylor <mataylor at shaw.ca> wrote:

> I am creating a script to backup my e-mail each night.  Attached is the 
> script, but my only problem is that it isn't doing any of the hidden 
> /directories or files.  I thought that tar would do this routinely?
> 

This is a bit different, but in case anyone is looking for a backup
script, here is mine. It's a bit of a hack, but it works...


#!/bin/sh

#	Do backups using tar
#		first clean up files that should not be backed up (like deleted mail)
#		then create a list of files newer than the last backup
#		delete items from list that don't get backed up (mozilla cache for example)
#		save the current time by touching a file
#		tar the listed files to a compressed tar file

#	Clean up extraneous files

echo "Cleaning up mail"
find /home/ajackson/Mail \( -name ',[0-9]*' \) -ls -exec rm {} \;
rm ~ajackson/.bak

#	first find all files newer than the .last_backup file 
#	that are not directories
#	Do not look in mounted filesystems (this prevents looking at the
#	DOS partitions

echo "Running find command"
/bin/rm -f /tmp/backups
/bin/rm -f /home/ajackson/.maildir/new/*

find /etc -newer /.last_backups ! -type d  ! -name "backtar.gz" -fprint /tmp/backups_all_etc

find /home/ajackson -newer /.last_backups ! -type d  ! -name "backtar.gz" ! -name "*.wav" ! -name "*.mp3" ! -name "*.ogg" -fprint /tmp/backups_all_home

cat /tmp/backups_all_etc /tmp/backups_all_home > /tmp/backups_all

#	remove stuff from file that doesn't get backed up

cat /tmp/backups_all | grep -i -v -E 'cache'  | grep -i -v 'glameswap' | grep -i -v 'tif' | grep -v 'trash' | grep -v 'backup' | grep -v 'queue' | grep -v 'thumbnails' > /tmp/backups

#	reset .last_backups file

touch /.last_backups

#	Create tar file

tar -cvzf /backtar.gz --files-from /tmp/backups

cp /backtar.gz /archive/backups/`date +%y%m%d:%H%M`.gz

echo "Tar file creation done. File is "
echo "`ls -als /backtar.gz`"

echo "File copied to /archive/backups/`date +%y%m%d:%H%M`.gz "


-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan at ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------


More information about the Linux-users mailing list