43 lines
1.3 KiB
Bash
43 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
# backup script for use with crontab
|
|
# i.e. every day at 3 a.m.
|
|
#
|
|
# 0 03 * * * /home/robin/backup_git_jtrac.sh
|
|
#
|
|
#
|
|
|
|
|
|
|
|
echo Starting backup script `date`
|
|
#cd /home/robin/git_backups
|
|
|
|
find ~/git_backups -name 'git_backup_*.tar' -prune -mtime +2 -exec rm -rf {} \;
|
|
|
|
date=`date | sed 's/ /_/g' | sed 's/:/./g'`
|
|
|
|
|
|
echo $date GIT DB backup running
|
|
echo tar cvfp ~/git_backups/git_backup_$date.tar /git/*
|
|
tar cvfp ~/git_backups/git_backup_$date.tar /git/*
|
|
# git compresses already so just use tar as a collector of files
|
|
# actually zcat-ing this gains very little space
|
|
|
|
#md5sum cvs_backup_$date.tar.gz > ~/etc_server/SYS/DEV/PROJECTS/CVS_BACKUP/md5sum_$date.txt
|
|
md5sum ~/git_backups/git_backup_$date.tar > /media/DEV/PROJECTS/GIT_BACKUP/md5sum_$date.txt
|
|
cp ~/git_backups/git_backup_$date.tar /media/DEV/PROJECTS/GIT_BACKUP
|
|
|
|
|
|
echo "----------------------------------- pruning old back-ups-----------------------------"
|
|
|
|
#
|
|
# delete archive files older than 15 days from the CVS_BACKP folder
|
|
#
|
|
# find ~/etc_server/SYS/DEV/PROJECTS/CVS_BACKUP -name 'cvs_backup_*.tar.gz' -prune -mtime +15 -exec rm -rf {} \;
|
|
find /media/DEV/PROJECTS/GIT_BACKUP -name 'md5sum_*.txt' -prune -mtime +15 -exec rm -rf {} \;
|
|
|
|
|
|
|
|
#########################################################################################################
|