Kompai Paskaitos

backup script bash tar bzip2

touch /
mkdir /backup
chmod a+x /

cd /backup
file="`date +%Y%m%d-%H%M%S`.tar"
#echo $file
tar -cf new.backup/$file folder_to_backup
cd /backup/new.backup
bzip2 -zq9 $file
#rm $failas
echo "backed up `date` \n" >> /backup/backup.made
#remove older then 3 days to /backup/old.backup
find -type f -mtime +3 -exec mv {} ../old.backup/ \;
cd ../old.backup
# completely remove backups, older then 7 days
find -type f -mtime +7 -exec rm -f {} ../old.backup/ \;

By Ruslanas Gžibovskis

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.