X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=init.d%2Fsfa;h=7c51b48896d23bd5b5fdea9d3fdc200577486326;hb=e4f6366c4d6dd7f98c25e4ab8a0a723438540ae4;hp=885865a5be8d7397099df0bd93fb0859aac2d6b5;hpb=6f0a757c5adf47b4d222cec09514dcd688b93457;p=sfa.git diff --git a/init.d/sfa b/init.d/sfa index 885865a5..7c51b488 100755 --- a/init.d/sfa +++ b/init.d/sfa @@ -59,6 +59,18 @@ function postgresql_check () { return 1 } +# use a single date of this script invocation for the dump_*_db functions. +DATE=$(date +"%Y-%m-%d-%H-%M-%S") + +# Dumps the database - optional argument to specify filename suffix +function dump_sfa_db() { + if [ -n "$1" ] ; then suffix="-$1" ; else suffix="" ; fi + mkdir -p /usr/share/sfa/backups + dumpfile=/usr/share/sfa/backups/$(date +"${SFA_DB_NAME}.${DATE}${suffix}.sql") + pg_dump -U $SFA_DB_USER $SFA_DB_NAME > $dumpfile + echo "Saved sfa database in $dumpfile" + check +} # Regenerate configuration files - almost verbatim from plc.init function reload () { @@ -246,6 +258,7 @@ function start() { reload db_start + # migrations are now handled in the code by sfa.storage.dbschema # install peer certs action $"SFA installing peer certs" daemon /usr/bin/sfa-start.py -t -d $OPTIONS @@ -287,8 +300,11 @@ case "$1" in status sfa-start.py RETVAL=$? ;; + dbdump) + dump_sfa_db + ;; *) - echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" + echo $"Usage: $0 {start|stop|reload|restart|condrestart|status|dbdump}" exit 1 ;; esac