User Tools

Site Tools


my_backup_pi_scripts

This is an old revision of the document!


My Backup Pi Scripts



These are the scripts the backup pi is using to pull all the files from the webserver and wiki pi's. There are two scripts:

1. The backup script for webserver1 (cameraangle and shotlive) 2. The backup script for the wiki server

These are both run once a week by a cron job (sudo crontab -e)

Webserver1 Script


  #!/bin/bash
  #
  # Script to backup webserver and wiki pi's
  #
  #
  # Alan Walker - Aug 2016
  #
  #
  # stuff this script does
  # backup (rsync) cpg15x on webserver1
  # backup ShotLive on webserver1
  # backup (mysqldump) database on webserver1
  # backup wiki (rsync) on wiki pi
  #
  #
  # backup (rsync) cpg15x on webserver1
  # create new backup folder
  echo "Creating folder /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d')
  # make a folder with the current date
  mkdir /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')
  #
  #
  # copy files from cpg15x on webserver to this server
  echo "Copying cpg15x files to /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d')
  rsync -avzh pi@192.168.1.10:/home/pi/cpg15x /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')
  #
  #
  # copy files from ShotLive on webserver to this server
  echo "Copying ShotLive files to /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d')
  rsync -avzh pi@192.168.1.10:/home/pi/ShotLive /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')
  #
  #
  # Backup MySQL Database (the one database is used for both ShotLive and Cameraangle)
  echo "Backup database to /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d')
  mysqldump --host 192.168.1.10 -P 3306 -u Username -pPassword alan_gallery > /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')/alan_gallery.sql
  #
  #
  echo ""
  echo "Finished"
  
  
  NOTE: The username and password have been removed from the SQL script



my_backup_pi_scripts.1470334457.txt.gz · Last modified: 2023/03/09 22:35 (external edit)