Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # backup.sh - Backup eLabFTW installation
- # ------
- # CONFIG
- # ------
- BACKUP_DIR='~/.backups/elabftw'
- ELAB_ROOT='/var/www/html/elabftw'
- DB_HOST='localhost'
- DB_NAME='elabftw'
- DB_USER='elabftw'
- DB_PASSWORD='secr3t'
- # ----------
- # END CONFIG
- # ----------
- # create the dir if it's not here already
- mkdir -p ${BACKUP_DIR}
- # get clean date
- date=$(date --iso-8601) # 2016-02-10
- # elab sql backup
- #################
- # make a dump of the database in elabftw.sql file
- mysqldump -h${DB_HOST} -u${DB_USER} -p${DB_PASSWORD} -r dump.sql ${DB_NAME}
- # compress the file
- gzip dump.sql
- # copy this file somewhere else using ssh (scp)
- # this requires to have ssh correctly configured with public key authentication
- #scp -q ${DB_NAME}.sql.gz user@computer:.backups/elabftw-${date}.sql.gz
- # move the file to a local backup dir
- mv dump.sql.gz ${BACKUP_DIR}/elabftw-${date}.sql.gz
- # if the backup is to different filesystem such as a smb or afp share use the following code
- #cp --no-preserve=mode dump.sql.gz ${BACKUP_DIR}/elabftw-${date}.sql.gz
- #rm dump.sql.gz
- # uploaded files backup
- #######################
- # make a zip of the uploads folder
- zip -rq archive.zip ${ELAB_ROOT}/uploads
- # add the config file
- zip -rq archive.zip ${ELAB_ROOT}/config.php
- # copy the tarball to somewhere else using ssh (scp)
- #scp -q archive.zip user@computer:.backups/elabftw-${date}.zip
- # move the file to a local backup dir
- mv archive.zip ${BACKUP_DIR}/elabftw-${date}.zip
- # if the backup is to different filesystem such as a smb or afp share use the following code
- #cp --no-preserve=mode archive.zip ${BACKUP_DIR}/elabftw-${date}.zip
- #rm archive.zip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement