Added dbbackup.sh - mySQL DB Backup

Added svnbackup.sh - Backup SVN Repo
Added wwwbackup.sh - Backup /var/www
This commit is contained in:
Matthew McKinnon 2014-11-27 00:27:17 +10:00
parent 7bc383bc94
commit 9be8bfc504
3 changed files with 55 additions and 0 deletions

17
dbbackup.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
bakdate=$(date +%Y%m%d%H%M)
DBUSER='dbbackup'
DBPASS='EWFfP3GZsqr427Yj'
BACKUPDIR='/BACKUP/db/'
databases=`mysql --user=$DBUSER --password=$DBPASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
mysqldump --force --opt --user=$DBUSER --password=$DBPASS --databases $db > $BACKUPDIR/`date +%Y%m%d`.$db.sql
fi
done

26
svnbackup.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
bakdate=$(date +%Y%m%d%H%M)
echo "--------------------------------"
echo "Running SVN backup $bakdate"
echo "--------------------------------\n"
svnrepos="/var/lib/svn"
echo "\nGoing to backup all SVN repos located at: $svnrepos \n"
bakdest="/BACKUP/svn/"
cd $svnrepos
if [ -d "$bakdest" ] && [ -w "$bakdest" ] ; then
for repo in *; do
echo "Taking backup/svndump for: $repo"
echo "Executing : svnadmin dump $repo > $bakdest/$repo-$bakdate.svn.dump \n"
svnadmin dump $repo > $bakdest/$repo-$bakdate.svn.dump
done
else
echo "Unable to continue SVN backup process."
echo "$bakdest is *NOT* a directory or you do not have write permission."
fi
echo "\n\n================================="
echo " - Backup Complete, THANK YOU :-]"

12
wwwbackup.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
DATE=$(date +%Y%m%d%H%M)
BACKUPDIR='/BACKUP/www'
WWW='/var/www/'
cd $WWW
for folder in `ls -d *`; do
tar -zcvf $BACKUPDIR/$folder-$DATE.tar.gz $folder
done