my_backup_pi_scripts
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
my_backup_pi_scripts [2016/11/06 17:51] – walkeradmin | my_backup_pi_scripts [2016/11/06 18:38] – walkeradmin | ||
---|---|---|---|
Line 11: | Line 11: | ||
\\ | \\ | ||
\\ | \\ | ||
- | ===== Webserver1 Script (wevsvr1backup) Latest ===== | + | ===== Webserver1 Script (wikibackup) Latest ===== |
< | < | ||
#!/bin/bash | #!/bin/bash | ||
Line 18: | Line 18: | ||
# | # | ||
# | # | ||
- | # Alan Walker - Aug 2016 | + | # Alan Walker - Nov 2016 |
# | # | ||
# | # | ||
Line 32: | Line 32: | ||
# make a folder with the current date | # make a folder with the current date | ||
mkdir / | mkdir / | ||
- | # | ||
# | # | ||
# copy files from cpg15x on webserver to this server | # copy files from cpg15x on webserver to this server | ||
echo " | echo " | ||
- | sudo sshpass -p "Cr00kh0rn52.." rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group | + | sudo sshpass -p "Password" rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group |
- | # | + | |
# | # | ||
# copy files from ShotLive on webserver to this server | # copy files from ShotLive on webserver to this server | ||
echo " | echo " | ||
#sudo rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group | #sudo rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group | ||
- | sudo sshpass -p "Cr00kh0rn52.." rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group | + | sudo sshpass -p "Password" rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group |
- | # | + | |
# | # | ||
# Backup MySQL Database (the one database is used for both ShotLive and Cameraangle) | # Backup MySQL Database (the one database is used for both ShotLive and Cameraangle) | ||
echo " | echo " | ||
- | sudo mysqldump --host 192.168.1.9 -P 3306 -u walkeradmin | + | sudo mysqldump --host 192.168.1.9 -P 3306 -u username |
- | # | + | |
- | #mysqldump --host 192.168.1.9 -P 3306 -u walkeradmin -pCr00kh0rn52.. alan_gallery > / | + | |
# | # | ||
# | # | ||
Line 55: | Line 50: | ||
echo " | echo " | ||
</ | </ | ||
- | \\ | ||
- | \\ | ||
- | ===== Webserver1 Script (wevsvr1backup) Original ===== | ||
- | #!/bin/bash | ||
- | # | ||
- | # Script to backup webserver pi | ||
- | # | ||
- | # | ||
- | # Alan Walker - Aug 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 " | ||
- | # make a folder with the current date | ||
- | mkdir / | ||
- | # | ||
- | # | ||
- | # copy files from cpg15x on webserver to this server | ||
- | echo " | ||
- | rsync -avzh pi@192.168.1.10:/ | ||
- | # | ||
- | # | ||
- | # copy files from ShotLive on webserver to this server | ||
- | echo " | ||
- | rsync -avzh pi@192.168.1.10:/ | ||
- | # | ||
- | # | ||
- | # Backup MySQL Database (the one database is used for both ShotLive and Cameraangle) | ||
- | echo " | ||
- | mysqldump --host 192.168.1.10 -P 3306 -u Username -pPassword alan_gallery > / | ||
- | # | ||
- | # | ||
- | echo "" | ||
- | echo " | ||
- | | ||
- | | ||
- | NOTE: The username and password have been removed from the SQL script | ||
\\ | \\ | ||
\\ | \\ | ||
===== Wiki Server Backup Script (wikibackup) ===== | ===== Wiki Server Backup Script (wikibackup) ===== | ||
- | | + | < |
- | # | + | # |
- | # Script to backup wiki pi | + | # |
- | # | + | # Script to backup wiki pi |
- | # | + | # |
- | # Alan Walker - Aug 2016 | + | # |
- | # | + | # Alan Walker - Nov 2016 |
- | # | + | # |
- | # stuff this script does | + | # |
- | # | + | # stuff this script does |
- | # backup wiki (rsync) on wiki pi | + | # |
- | # | + | # backup wiki (rsync) on wiki pi |
- | # | + | # |
- | # backup (rsync) wiki server | + | # |
- | # create new backup folder | + | # backup (rsync) wiki server |
- | echo " | + | # create new backup folder |
- | # make a folder with the current date | + | echo " |
- | mkdir /mnt/usbstorage/backups/ | + | # make a folder with the current date |
- | # | + | mkdir /home/pi/Backups/ |
- | # | + | # |
- | | + | # copy files from / |
- | echo " | + | echo " |
- | rsync -avzh pi@192.168.1.11:/home/pi/dokuwiki /mnt/usbstorage/backups/ | + | # |
- | # | + | # |
- | # | + | sudo sshpass -p " |
- | echo "" | + | # |
- | echo " | + | # |
- | \\ | + | echo "" |
+ | echo " | ||
+ | |||
+ | </ | ||
\\ | \\ | ||
===== Cron Automation ===== | ===== Cron Automation ===== | ||
- | To automate this process, I am using the following Cron job (use sudo Crontab | + | To automate this process, I am using the following Cron job (use crontab |
\\ | \\ | ||
\\ | \\ | ||
- | # Edit this file to introduce tasks to be run by cron. | + | <file> |
- | # | + | # This job is to backup the webserver files and database at 3am every sunday |
- | # Each task to run has to be defined through a single line | + | 0 3 * * 0 / |
- | # indicating with different fields when the task will be run | + | 0 4 * * 0 / |
- | # and what command to run for the task | + | # |
- | # | + | # |
- | # To define the time you can provide concrete values for | + | # This job is to backup the wiki server every sunday at 2am |
- | # minute (m), hour (h), day of month (dom), month (mon), | + | #5 * * * * / |
- | # and day of week (dow) or use ' | + | 0 1 * * 0 / |
- | # Notice that tasks will be started based on the cron's system | + | 0 2 * * 0 / |
- | # daemon' | + | </ |
- | # | + | |
- | # Output of the crontab jobs (including errors) is sent through | + | |
- | # email to the user the crontab file belongs to (unless redirected). | + | |
- | # | + | |
- | # For example, you can run a backup of all your user accounts | + | |
- | # at 5 a.m every week with: | + | |
- | # 0 5 * * 1 tar -zcf / | + | |
- | # | + | |
- | # For more information see the manual pages of crontab(5) and cron(8) | + | |
- | # | + | |
- | # m h dom mon dow | + | |
- | # | + | |
- | # | + | |
- | | + | |
- | 00 03 * * 0 / | + | |
- | # | + | |
- | # | + | |
- | # This job is to backup the wiki server every sunday at 3am | + | |
- | 00 02 * * 0 / | + | |
\\ | \\ | ||
\\ | \\ |
my_backup_pi_scripts.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1