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/08/04 19:14] – walkeradmin | my_backup_pi_scripts [2016/11/06 18:36] – walkeradmin | ||
---|---|---|---|
Line 11: | Line 11: | ||
\\ | \\ | ||
\\ | \\ | ||
- | ===== Webserver1 Script ===== | + | ===== Webserver1 Script |
- | # | + | < |
- | # | + | # |
- | # Script to backup webserver | + | # |
- | # | + | # Script to backup webserver pi |
- | # | + | # |
- | # Alan Walker - Aug 2016 | + | # |
- | # | + | # Alan Walker - Nov 2016 |
- | # | + | # |
- | # stuff this script does | + | # |
- | # backup (rsync) cpg15x on webserver1 | + | # stuff this script does |
- | # backup ShotLive on webserver1 | + | # backup (rsync) cpg15x on webserver1 |
- | # backup (mysqldump) database on webserver1 | + | # backup ShotLive on webserver1 |
- | # backup wiki (rsync) on wiki pi | + | # 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 " | ||
+ | sudo sshpass -p " | ||
+ | # | ||
+ | # copy files from ShotLive on webserver to this server | ||
+ | echo " | ||
+ | #sudo rsync --verbose --recursive --perms --executability --acls --xattrs --owner --group | ||
+ | sudo sshpass -p " | ||
+ | # | ||
+ | # Backup MySQL Database (the one database is used for both ShotLive and Cameraangle) | ||
+ | echo " | ||
+ | sudo mysqldump --host 192.168.1.9 -P 3306 -u username -pPassword alan_gallery > / | ||
+ | # | ||
+ | # | ||
+ | echo "" | ||
+ | echo " | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Wiki Server Backup Script (wikibackup) ===== | ||
+ | < | ||
+ | # | ||
+ | # | ||
+ | # Script to backup wiki pi | ||
+ | # | ||
+ | # | ||
+ | # Alan Walker - Nov 2016 | ||
+ | # | ||
+ | # | ||
+ | # stuff this script does | ||
+ | # | ||
+ | # backup wiki (rsync) on wiki pi | ||
+ | # | ||
+ | # | ||
+ | # backup (rsync) wiki server | ||
+ | # create new backup folder | ||
+ | echo " | ||
+ | # make a folder with the current date | ||
+ | mkdir / | ||
+ | # | ||
+ | # copy files from / | ||
+ | echo " | ||
+ | # | ||
+ | # | ||
+ | sudo sshpass -p " | ||
+ | # | ||
+ | # | ||
+ | echo "" | ||
+ | echo " | ||
+ | |||
+ | </ | ||
+ | \\ | ||
+ | ===== 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), |
- | | + | |
- | # make a folder with the current date | + | # Notice that tasks will be started based on the cron's system |
- | | + | |
# | # | ||
+ | # 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 |
- | | + | |
- | | + | |
# | # | ||
+ | # 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 |
- | echo " | + | |
- | rsync -avzh pi@192.168.1.10:/ | + | |
# | # | ||
# | # | ||
- | # Backup MySQL Database (the one database | + | # This job is to backup |
- | | + | |
- | mysqldump --host 192.168.1.10 -P 3306 -u Username -pPassword alan_gallery > / | + | |
# | # | ||
# | # | ||
- | | + | |
- | | + | |
- | + | ||
- | + | ||
- | 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