Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Comrade:MxAsh/AdminNotes/backup: Difference between revisions

More languages
(Created page with "=== on the server === We have a crontab running every 6 hours that runs a database backup: <pre># crontab -l | grep db_backup 10 */6 * * * /root/db_backup.sh >/dev/null 2>&1</...")
 
mNo edit summary
Line 22: Line 22:


If you run this yourself you'll need to change the "shebang" line referencing bash, and the backupdir.
If you run this yourself you'll need to change the "shebang" line referencing bash, and the backupdir.
<pre>#!/opt/homebrew/bin/bash -x
<pre>$ cat bin/wikibackup_pull.sh
#!/opt/homebrew/bin/bash -x


backupdir='/Volumes/home/Misc_Backups/prolewiki'
backupdir='/Volumes/home/Misc_Backups/prolewiki' # change to your local backup directory


if [[ ! -d ${backupdir} ]]; then
if [[ ! -d ${backupdir} ]]; then

Revision as of 00:53, 26 December 2020

on the server

We have a crontab running every 6 hours that runs a database backup:

# crontab -l | grep db_backup
10 */6 * * * /root/db_backup.sh >/dev/null 2>&1
$ cat /root/db_backup.sh
#!/usr/bin/bash -x

backupdir='/root/databases'
datestamp="$(date +%Hh%d-%m-%Y)"

if [[ ${EUID} -ne 0 ]]; then
  echo "This program expects to be run as root." 1>&2
  exit 127
fi

mysqldump --add-drop-database --log-error=${backupdir}/pw-server_all_${datestamp}.sql.log --verbose --result-file=${backupdir}/pw-server_all_${datestamp}.sql --all-databases
find ${backupdir} -mtime +1 -print -delete 2>&1 | tee ${backupdir}/pw-server_all_${datestamp}.cleanup.log

local backup script

TODO

  • some kind of archival and/or versioning of the webroot? (right now I get it from the backup host filesystem)

If you run this yourself you'll need to change the "shebang" line referencing bash, and the backupdir.

$ cat bin/wikibackup_pull.sh
#!/opt/homebrew/bin/bash -x

backupdir='/Volumes/home/Misc_Backups/prolewiki' # change to your local backup directory

if [[ ! -d ${backupdir} ]]; then
  echo "Cannot access backup directory \`${backupdir}\`, is nas2 mounted?" 1>&2
  exit 2
fi

time rsync -ave 'ssh -p 22022' --delete root@www.prolewiki.org:/home/prole/public_html/ ${backupdir}/public_html/ 2>&1 | tee ${backupdir}/public_html_rsync.log
time rsync -ave 'ssh -p 22022' --delete root@www.prolewiki.org:/root/databases/ ${backupdir}/database/ 2>&1 | tee ${backupdir}/databases_rsync.log