User Tools

Site Tools


my_backup_pi_scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
my_backup_pi_scripts [2016/08/04 19:14] walkeradminmy_backup_pi_scripts [2016/11/06 18:36] walkeradmin
Line 11: Line 11:
 \\  \\ 
 \\  \\ 
-===== Webserver1 Script =====+===== Webserver1 Script (wikibackup) Latest ===== 
 +<file> 
 +#!/bin/bash 
 +
 +# Script to backup webserver pi 
 +
 +
 +# Alan Walker - Nov 2016 
 +
 +
 +# stuff this script does 
 +# backup (rsync) cpg15x on webserver1 
 +# backup ShotLive on webserver1 
 +# backup (mysqldump) database on webserver1 
 +
 +
 +# 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 /home/pi/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'
 +sudo sshpass -p "Password" rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group  pi@192.168.1.9:/mnt/usbhdd/cpg15x /home/pi/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'
 +#sudo rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group  pi@192.168.1.10:/home/pi/ShotLive /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d'
 +sudo sshpass -p "Password" rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group  pi@192.168.1.9:/mnt/usbhdd/ShotLive /home/pi/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'
 +sudo mysqldump --host 192.168.1.9 -P 3306 -u username -pPassword alan_gallery > /home/pi/Backups/webserver1/$(date '+%Y-%m-%d')/alan_gallery.sql 
 +
 +
 +echo "" 
 +echo "Finished" 
 +</file>
 \\  \\ 
-    #!/bin/bash +\\  
-    +===== Wiki Server Backup Script (wikibackup) ===== 
-    # Script to backup webserver and wiki pi's +<file> 
-    +#!/bin/bash 
-    +
-    # Alan Walker - Aug 2016 +# Script to backup wiki pi 
-    +
-    +
-    # stuff this script does +# Alan Walker - Nov 2016 
-    # backup (rsync) cpg15x on webserver1 +
-    backup ShotLive on webserver1 +
-    # backup (mysqldumpdatabase on webserver1 +# stuff this script does 
-    # backup wiki (rsync) on wiki pi+
 +# backup wiki (rsync) on wiki pi 
 +# 
 +
 +# backup (rsyncwiki server 
 +create new backup folder 
 +echo "Creating folder /mnt/usbstorage/backups/wiki/"$(date '+%Y-%m-%d') 
 +# make a folder with the current date 
 +mkdir /home/pi/Backups/wiki/$(date '+%Y-%m-%d'
 +
 +# copy files from /home/pi/dokuwiki on wiki server to this server 
 +echo "Copying dokuwiki files to /home/pi/Backups/wiki/"$(date '+%Y-%m-%d'
 +
 +
 +sudo sshpass -p "Password" rsync --super --verbose --recursive --perms --executability --acls --xattrs --owner --group  pi@192.168.1.9:/mnt/usbhdd/dokuwiki /home/pi/Backups/wiki/$(date '+%Y-%m-%d'
 +
 +
 +echo "" 
 +echo "Finished" 
 + 
 +</file> 
 +\\  
 +===== Cron Automation ===== 
 +To automate this process, I am using the following Cron job (use sudo Crontab -e) 
 +\\  
 +\\  
 +    # Edit this file to introduce tasks to be run by cron.
     #     #
 +    # Each task to run has to be defined through a single line
 +    # indicating with different fields when the task will be run
 +    # and what command to run for the task
     #     #
-    # backup (rsync) cpg15x on webserver1 +    # To define the time you can provide concrete values for 
-    # create new backup folder +    # minute (m), hour (h), day of month (dom), month (mon), 
-    echo "Creating folder /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d') +    # and day of week (dow) or use '*' in these fields (for 'any').# 
-    # make a folder with the current date +    # Notice that tasks will be started based on the cron's system 
-    mkdir /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')+    # daemon's notion of time and timezones.
     #     #
 +    # Output of the crontab jobs (including errors) is sent through
 +    # email to the user the crontab file belongs to (unless redirected).
     #     #
-    # copy files from cpg15x on webserver to this server +    # For example, you can run a backup of all your user accounts 
-    echo "Copying cpg15x files to /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d') +    # at 5 a.every week with: 
-    rsync -avzh pi@192.168.1.10:/home/pi/cpg15x /mnt/usbstorage/backups/webserver1/$(date '+%Y-%m-%d')+    # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
     #     #
 +    # For more information see the manual pages of crontab(5) and cron(8)
     #     #
-    # copy files from ShotLive on webserver to this server +    # m h  dom mon dow   command
-    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) +    # This job is to backup the webserver files and database at 3am every sunday 
-    echo "Backup database to /mnt/usbstorage/backups/webserver1/"$(date '+%Y-%m-%d'+    00 03 * * 0 /mnt/usbstorage/backups/scripts/websvr1backup | tee /mnt/usbstorage/backups/logs/$(date '+%Y-%m-%d')-websvr1backup.log
-    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 "" +    # This job is to backup the wiki server every sunday at 3am 
-    echo "Finished" +    00 02 * * 0 /mnt/usbstorage/backups/scripts/wikibackup | tee /mnt/usbstorage/backups/logs/$(date '+%Y-%m-%d')-wikiba$
-     +
-     +
-    NOTE: The username and password have been removed from the SQL script+
 \\  \\ 
 \\  \\ 
 +
 +
 +
 +
  
  
my_backup_pi_scripts.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1