Updates backup script, adds database backup script and modifies extract script
This commit is contained in:
parent
fea427cb1e
commit
3064491345
3 changed files with 26 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
#Directory on the server to backup to
|
||||
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")
|
||||
echo ${LATEST##*\/}
|
||||
echo ${TODAY}
|
||||
|
@ -17,13 +17,13 @@ fi
|
|||
#Backup sites directory
|
||||
rsync --archive --one-file-system --hard-links --human-readable --inplace\
|
||||
--exclude-from=./backupExcludes\
|
||||
--link-dest=${LATEST}\
|
||||
--link-dest=${BACKUPDIR}${LATEST}\
|
||||
~/Sites officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
|
||||
|
||||
#Backup Documents Directory
|
||||
rsync --archive --one-file-system --hard-links --human-readable --inplace\
|
||||
--exclude-from=./backupExcludes\
|
||||
--link-dest=${LATEST}\
|
||||
--link-dest=${BACKUPDIR}${LATEST}\
|
||||
~/Documents officeServerJH:/mnt/TimeMachine/Backup-JH/backups/${TODAY}/ --verbose
|
||||
|
||||
#At some point, add ability to delete old backups
|
||||
|
|
15
bin/backupDatabases
Executable file
15
bin/backupDatabases
Executable file
|
@ -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
|
||||
fi
|
||||
;;
|
||||
*.rar)
|
||||
if [ "$2" ]; then
|
||||
#tar xvf $1 -C $2
|
||||
echo "Look into how to unrar into directory"
|
||||
else
|
||||
unrar x $1
|
||||
fi
|
||||
;;
|
||||
*.tar)
|
||||
if [ "$2" ]; then
|
||||
tar xvf $1 -C $2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue