general git backup script to be used with rsynch perhaps to synology

This commit is contained in:
robin 2021-10-22 15:04:35 +00:00
parent a4062f84fd
commit 7d1e1e0fcd

42
backup_git.sh Normal file
View File

@ -0,0 +1,42 @@
#!/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 {} \;
#########################################################################################################