Updates backup script, adds database backup script and modifies extract script

Jonathan Hodgson 6 years ago
parent eb54b254ca
commit 0651268cba
  1. 6
      bin/backup
  2. 15
      bin/backupDatabases
  3. 8
      bin/extract

@ -2,7 +2,7 @@
#Directory on the server to backup to #Directory on the server to backup to
BACKUPDIR='/mnt/TimeMachine/Backup-JH/backups/' BACKUPDIR='/mnt/TimeMachine/Backup-JH/backups/'
LATEST=$(ssh officeServerJH find ${BACKUPDIR} -type d -depth 1 | sort | tail -n 1) LATEST=$(ssh officeServerJH ls ${BACKUPDIR} | sort | tail -n 1)
TODAY=$(date -I -d "today") TODAY=$(date -I -d "today")
echo ${LATEST##*\/} echo ${LATEST##*\/}
echo ${TODAY} echo ${TODAY}
@ -17,13 +17,13 @@ fi
#Backup sites directory #Backup sites directory
rsync --archive --one-file-system --hard-links --human-readable --inplace\ rsync --archive --one-file-system --hard-links --human-readable --inplace\
--exclude-from=./backupExcludes\ --exclude-from=./backupExcludes\
--link-dest=${LATEST}\ --link-dest=${BACKUPDIR}${LATEST}\
~/Sites officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose ~/Sites officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
#Backup Documents Directory #Backup Documents Directory
rsync --archive --one-file-system --hard-links --human-readable --inplace\ rsync --archive --one-file-system --hard-links --human-readable --inplace\
--exclude-from=./backupExcludes\ --exclude-from=./backupExcludes\
--link-dest=${LATEST}\ --link-dest=${BACKUPDIR}${LATEST}\
~/Documents officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose ~/Documents officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
#At some point, add ability to delete old backups #At some point, add ability to delete old backups

@ -0,0 +1,15 @@
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="$HOME/Sites/db-backups"
MYSQL_USER="root"
MYSQL_PASSWORD="root"
MYSQL=/opt/lampp/bin/mysql
MYSQLDUMP=/opt/lampp/bin/mysqldump
mkdir -p "$BACKUP_DIR"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$db-$TIMESTAMP.sql.gz"
done

@ -31,6 +31,14 @@ if [ -f $1 ] ; then
gunzip $1 gunzip $1
fi fi
;; ;;
*.rar)
if [ "$2" ]; then
#tar xvf $1 -C $2
echo "Look into how to unrar into directory"
else
unrar x $1
fi
;;
*.tar) *.tar)
if [ "$2" ]; then if [ "$2" ]; then
tar xvf $1 -C $2 tar xvf $1 -C $2

Loading…
Cancel
Save