Difference between revisions of "Cedeus DB backups"

From stgo
Jump to: navigation, search
(dump of the GeoNode DB - on CedeusDB)
(file transfer can be accomplished using scp)
Line 26: Line 26:
 
* to see what the cron tab contains use "<code>crontab -l</code>"
 
* to see what the cron tab contains use "<code>crontab -l</code>"
  
==== file transfer can be accomplished using scp ====
+
==== File transfer ====
e.g.:
+
can be accomplished using '''scp''' e.g.:
 
*: "<code>scp /home/ssteinig/ftw.txt user@example.com:/home/ssteinig/dbbackups/</code>"
 
*: "<code>scp /home/ssteinig/ftw.txt user@example.com:/home/ssteinig/dbbackups/</code>"
 
** However, a ssh key should be generated first so no password needs to be provided. See: http://troy.jdmz.net/rsync/index.html
 
** However, a ssh key should be generated first so no password needs to be provided. See: http://troy.jdmz.net/rsync/index.html

Revision as of 16:08, 3 December 2014

>> return to Cedeus_IDE


How to set up Backups

notifications

To get notified about the backups via email, a/the shell script may send emails via "mailx" - i.e Nail. => see http://klenwell.com/press/2009/03/ubuntu-email-with-nail/

Btw. postfix may work as well

=> ToDo: Install mail program

dump of the GeoNode DB - on CedeusDB

  • create a shell script that contains the pgdump instructions - see /home/ssteinig/pgdbbackup.sh on CedeusDB
  • test if script or script execution actually works. A simple script for testing may perhaps be this (/home/ssteinig/touchy.sh)
#!/bin/bash 
touch /home/ssteinig/ftw.text

File transfer

can be accomplished using scp e.g.:

  • "scp /home/ssteinig/ftw.txt user@example.com:/home/ssteinig/dbbackups/"
    • However, a ssh key should be generated first so no password needs to be provided. See: http://troy.jdmz.net/rsync/index.html
    • "ssh-keygen -t rsa -b 2048 -f /home/thisuser/cron/thishost-rsync-key" and copy the key to the other servers users .ssh folder
    • then we would use "scp -i /home/ssteinig/ftw.txt user@example.com:/home/ssteinig/dbbackups/"
    • note that it is necessary to initialize it once (with whatever file), so the connextion gets an ECDDSA key fingerprint.

Example geonodegisdb93backup.sh

#!/bin/bash
logfile="/home/ssteinig/geonode_db_backups/pgsql.log"
backup_dir="/home/ssteinig/geonode_db_backups"
touch $logfile

echo "Starting backup of databases " >> $logfile
dateinfo=`date '+%Y-%m-%d %H:%M:%S'`
timeslot=`date '+%Y%m%d-%H%M'`
/usr/bin/vacuumdb -z -h localhost -U postgres geonodegisdb93  >/dev/null 2>&1
/usr/bin/pg_dump -U postgres -i -F c -b geonodegisdb93 -h 127.0.0.1 -f $backup_dir/geonodegisdb93-backup-$timeslot.backup
echo "Backup and Vacuum complete on $dateinfo for database: geonodegisdb93 " >> $logfile
echo "Done backup of databases " >> $logfile
# sstein: email notification not used at the moment
# tail -16 /home/ssteinig/geonode_db_backups/pgsql.log | mailx blabla@blub.cl

This example is based on the shell script posted here: http://stackoverflow.com/questions/854200/how-do-i-backup-my-postgresql-database-with-cron For a better Postgres dump script it may be worth to look here: https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux

dump of the GeoNode user db - on CedeusGeonode VM

blabla

tar/zip of the (uploaded) GeoNode file data and docs - on CedeusGeonode Vm

blabla

MySQL dump for Elgg miCiudad - on CedeusGeonode VM

blabla

tar/zip of the (uploaded) Elgg miCiudad files - on CedeusGeonode VM

blabla

MySQL dump for Mediawiki(s) - on CedeusGeonode VM

blabla