VPS Backup

From richmondmakerlabs.uk
Revision as of 03:34, 2 May 2019 by Beardedfool (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Scripts to backup VPS

SQL

  • Controlled by cronjob on proxrml (hostname PVE) which also invoked scripts on VPS (hostname rml) through ssh
  • Scripts quick and dirty and intentionally modular as will look to move functions over to ansible or similar - these are copied so check on servers for latest versions

0 */6 * * * /root/scripts/backup-VPS-databases.sh

root@pve:~/scripts# cat /root/scripts/backup-VPS-databases.sh
ssh VPSroot /root/scripts/backup-all-sql.sh
/root/scripts/fetch-databases-from-VPS.sh
root@rml:~/scripts# cat /root/scripts/backup-all-sql.sh
#check the other script being called, or just copy the line with the new database to be added
/root/scripts/backup-db.sh wiki
/root/scripts/backup-db.sh wordpress
/root/scripts/backup-db.sh wp_eels
root@rml:~/scripts# cat /root/scripts/backup-db.sh
## backups the database given by argument - can't be arsed to script the search at the moment
prepend="$(date +\%Y-\%m-\%d-\%M-\%S)"
folder=/root/sqldumps
mkdir -p $folder
mysqldump -u root $1 > $folder/$prepend-$1.sql
root@pve:~/scripts# cat /root/scripts/fetch-databases-from-VPS.sh
rsync -avz --remove-source-files VPSroot:/root/sqldumps/* /storage/backups/VPS/databases/

Still to do

  • Mailman
  • Other parts of wiki -[1]
  1. -tar of .../wiki folder
  2. -XML dump of the wiki content


Output (automatically uploaded to wiki from scripts)

  • Script at /root/scripts/update-wiki-sql-backups.sh on proxrml
    • Can't output it here as it contains 'pre' tags


List of db backups on proxrml

Mon 13 May 03:00:03 UTC 2019
----------Live DB Sizes----------
Database name	Size (MB)
information_schema	0.00878906
mysql	0.68635941
performance_schema	0.00000000
wiki	675.02921295
wordpress	9.09375000
wp_eels	1.50391388
----------List of sql backups----------
total 4411284
drwxr-xr-x 2 root root      4096 May 13 03:00 .
drwxr-xr-x 3 root root      4096 May  2 04:12 ..
-rw-r--r-- 1 root root 313281859 May  2 12:45 2019-05-02_11-45-34-wiki.sql
-rw-r--r-- 1 root root   2616291 May  2 12:45 2019-05-02_11-45-41-wordpress.sql
-rw-r--r-- 1 root root    583459 May  2 12:45 2019-05-02_11-45-41-wp_eels.sql
-rw-r--r-- 1 root root 313338393 May  2 14:57 2019-05-02_13-57-37-wiki.sql
-rw-r--r-- 1 root root   2616291 May  2 14:57 2019-05-02_13-57-44-wordpress.sql
-rw-r--r-- 1 root root    583459 May  2 14:57 2019-05-02_13-57-45-wp_eels.sql
-rw-r--r-- 1 root root 315474262 May  2 18:00 2019-05-02_17-00-02-wiki.sql
-rw-r--r-- 1 root root   2616291 May  2 18:00 2019-05-02_17-00-08-wordpress.sql
-rw-r--r-- 1 root root    584275 May  2 18:00 2019-05-02_17-00-08-wp_eels.sql
-rw-r--r-- 1 root root 317738404 May  3 00:00 2019-05-02_23-00-03-wiki.sql
-rw-r--r-- 1 root root   2616291 May  3 00:00 2019-05-02_23-00-10-wordpress.sql
-rw-r--r-- 1 root root    584275 May  3 00:00 2019-05-02_23-00-10-wp_eels.sql
-rw-r--r-- 1 root root 322044549 May  3 06:00 2019-05-03_05-00-02-wiki.sql
-rw-r--r-- 1 root root   2616291 May  3 06:00 2019-05-03_05-00-08-wordpress.sql
-rw-r--r-- 1 root root    584275 May  3 06:00 2019-05-03_05-00-09-wp_eels.sql
-rw-r--r-- 1 root root 324304594 May  3 12:00 2019-05-03_11-00-05-wiki.sql
-rw-r--r-- 1 root root   2616291 May  3 12:00 2019-05-03_11-00-12-wordpress.sql
-rw-r--r-- 1 root root    584275 May  3 12:00 2019-05-03_11-00-12-wp_eels.sql
-rw-r--r-- 1 root root 326647248 May  3 18:00 2019-05-03_17-00-01-wiki.sql
-rw-r--r-- 1 root root   2616291 May  3 18:00 2019-05-03_17-00-08-wordpress.sql
-rw-r--r-- 1 root root    584275 May  3 18:00 2019-05-03_17-00-09-wp_eels.sql
-rw-r--r-- 1 root root 328871653 May  4 00:00 2019-05-03_23-00-02-wiki.sql
-rw-r--r-- 1 root root   2616851 May  4 00:00 2019-05-03_23-00-09-wordpress.sql
-rw-r--r-- 1 root root    583007 May  4 00:00 2019-05-03_23-00-10-wp_eels.sql
-rw-r--r-- 1 root root 341301525 May  5 03:00 2019-05-05_02-00-02-wiki.sql
-rw-r--r-- 1 root root   2616851 May  5 03:00 2019-05-05_02-00-09-wordpress.sql
-rw-r--r-- 1 root root    582677 May  5 03:00 2019-05-05_02-00-09-wp_eels.sql
-rw-r--r-- 1 root root 362101991 May  7 03:00 2019-05-07_02-00-02-wiki.sql
-rw-r--r-- 1 root root   2616851 May  7 03:00 2019-05-07_02-00-09-wordpress.sql
-rw-r--r-- 1 root root    584894 May  7 03:00 2019-05-07_02-00-10-wp_eels.sql
-rw-r--r-- 1 root root 382587665 May  9 03:00 2019-05-09_02-00-02-wiki.sql
-rw-r--r-- 1 root root   2620497 May  9 03:00 2019-05-09_02-00-11-wordpress.sql
-rw-r--r-- 1 root root    583520 May  9 03:00 2019-05-09_02-00-11-wp_eels.sql
-rw-r--r-- 1 root root 403630008 May 11 03:00 2019-05-11_02-00-02-wiki.sql
-rw-r--r-- 1 root root   2662396 May 11 03:00 2019-05-11_02-00-10-wordpress.sql
-rw-r--r-- 1 root root    583520 May 11 03:00 2019-05-11_02-00-10-wp_eels.sql
-rw-r--r-- 1 root root 424051456 May 13 03:00 2019-05-13_02-00-02-wiki.sql
-rw-r--r-- 1 root root   2676880 May 13 03:00 2019-05-13_02-00-12-wordpress.sql
-rw-r--r-- 1 root root    583520 May 13 03:00 2019-05-13_02-00-12-wp_eels.sql