Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #!/bin/sh
  2. # backup.sh - Backup eLabFTW installation
  3.  
  4. # ------
  5. # CONFIG
  6. # ------
  7. BACKUP_DIR='~/.backups/elabftw'
  8. ELAB_ROOT='/var/www/html/elabftw'
  9.  
  10. DB_HOST='localhost'
  11. DB_NAME='elabftw'
  12. DB_USER='elabftw'
  13. DB_PASSWORD='secr3t'
  14. # ----------
  15. # END CONFIG
  16. # ----------
  17.  
  18. # create the dir if it's not here already
  19. mkdir -p ${BACKUP_DIR}
  20.  
  21. # get clean date
  22. date=$(date --iso-8601) # 2016-02-10
  23.  
  24. # elab sql backup
  25. #################
  26.  
  27. # make a dump of the database in elabftw.sql file
  28. mysqldump -h${DB_HOST} -u${DB_USER} -p${DB_PASSWORD} -r dump.sql ${DB_NAME}
  29.  
  30. # compress the file
  31. gzip dump.sql
  32.  
  33. # copy this file somewhere else using ssh (scp)
  34. # this requires to have ssh correctly configured with public key authentication
  35. #scp -q ${DB_NAME}.sql.gz user@computer:.backups/elabftw-${date}.sql.gz
  36.  
  37. # move the file to a local backup dir
  38. mv dump.sql.gz ${BACKUP_DIR}/elabftw-${date}.sql.gz
  39.  
  40. # if the backup is to different filesystem such as a smb or afp share use the following code
  41. #cp --no-preserve=mode dump.sql.gz ${BACKUP_DIR}/elabftw-${date}.sql.gz
  42. #rm dump.sql.gz
  43.  
  44. # uploaded files backup
  45. #######################
  46.  
  47. # make a zip of the uploads folder
  48. zip -rq archive.zip ${ELAB_ROOT}/uploads
  49. # add the config file
  50. zip -rq archive.zip ${ELAB_ROOT}/config.php
  51.  
  52. # copy the tarball to somewhere else using ssh (scp)
  53. #scp -q archive.zip user@computer:.backups/elabftw-${date}.zip
  54.  
  55. # move the file to a local backup dir
  56. mv archive.zip ${BACKUP_DIR}/elabftw-${date}.zip
  57.  
  58. # if the backup is to different filesystem such as a smb or afp share use the following code
  59. #cp --no-preserve=mode archive.zip ${BACKUP_DIR}/elabftw-${date}.zip
  60. #rm archive.zip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement