Added backup script
This commit is contained in:
parent
823bd5b988
commit
6bdbd2039b
1 changed files with 33 additions and 0 deletions
33
backup.sh
Normal file
33
backup.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
#backup.sh /var/www/lfbackend OPTION
|
||||
#OPTION
|
||||
# - F FULL BACKUP
|
||||
# - T Only save images from today
|
||||
# - I Incremental Backup (Not implemented yet)
|
||||
# (OPTIONS T and I only apply for images)
|
||||
|
||||
#CRON
|
||||
#17 * * * * root cd /tmp && /var/www/lfbackend/backup.sh /var/www/lfbackend T
|
||||
#45 5 * * * root cd /tmp && /var/www/lfbackend/backup.sh /var/www/lfbackend F
|
||||
|
||||
OPTION=$2
|
||||
|
||||
source $1/.env
|
||||
|
||||
TS=`date +%Y%m%d%H%M%S`
|
||||
|
||||
mysqldump -u $DB_USERNAME -p$DB_PASSWORD -h $DB_HOST $DB_DATABASE > database.sql
|
||||
if [ "$OPTION" == "T" ]
|
||||
then
|
||||
tar -N "`date +%Y-%m-%d`" -zcvf images.tar.gz -C $1/public/staticimages/ .
|
||||
elif [ "$OPTION" == "I" ]
|
||||
then
|
||||
tar -zcvf images.tar.gz -C $1/public/staticimages/ .
|
||||
else
|
||||
tar -zcvf images.tar.gz -C $1/public/staticimages/ .
|
||||
fi
|
||||
|
||||
gzip -f database.sql
|
||||
tar -cvf backup_${TS}_${OPTION}.tar database.sql.gz images.tar.gz
|
||||
|
Loading…
Reference in a new issue