From: Michael K. <mic...@ip...> - 2018-09-29 21:37:27
|
Great thanks guys Ps I wrote a restore script whereby you can restore all files, a single file, or just the database. Seems to work well, especially the database restore. Not sure if its useful for anyone. tarsnap_restore <archive> [<fname>|db|all] -------------- if [ -z $2 ]; then echo;echo "No archive name provided"; echo exit fi if [ -z $3 ]; then echo;echo "No file(s) to restore"; echo exit else case $3 in "all") echo; echo "WARNING: This action will overwrite your current configuration files and database with the entire archive $2" echo "It will also stop and restart Asterisk cutting off any calls that may be in progress" read -p 'Do you know what you are doing? (y/N):' restore if [ "$restore" == "y" ] || [ "$restore" == "Y" ]; then echo; echo "Ok restoring all files now..."; echo /usr/bin/tarsnap -xvf "$2" -C /mnt/kd echo; echo "Restoring database..." echo "Shutting down Asterisk" service asterisk stop >/dev/null sleep 2 sqlite3 /mnt/kd/astdb.sqlite3 'DROP TABLE IF EXISTS astdb;' >/dev/null sqlite3 /mnt/kd/astdb.sqlite3 < /mnt/kd/astdb_contents.dump >/dev/null echo "Starting Asterisk" service asterisk start >/dev/null sleep 2 echo; echo "Restoration of archive $2 complete"; echo else echo; echo "Archive $2 was not restored"; echo fi ;; "db") echo; echo "WARNING: This action will overwrite your current database with the database in archive $2" echo "It will also stop and restart Asterisk cutting off any calls that may be in progress" read -p 'Do you know what you are doing? (y/N):' restore if [ "$restore" == "y" ] || [ "$restore" == "Y" ]; then echo; echo "Ok restoring database now..."; echo /usr/bin/tarsnap -xvf "$2" -C /mnt/kd astdb_contents.dump echo "Shutting down Asterisk" service asterisk stop >/dev/null sleep 2 sqlite3 /mnt/kd/astdb.sqlite3 'DROP TABLE IF EXISTS astdb;' >/dev/null sqlite3 /mnt/kd/astdb.sqlite3 < /mnt/kd/astdb_contents.dump >/dev/null echo "Starting Asterisk" service asterisk start >/dev/null sleep 2 echo; echo "Restoration of database from archive $2 complete"; echo else echo; echo "Database was not restored"; echo fi ;; *) echo; echo "WARNING: This action will overwrite the file $3 from the archive $2" read -p 'Do you know what you are doing? (y/N):' restore if [ "$restore" == "y" ] || [ "$restore" == "Y" ]; then echo "Ok restoring $3 now" /usr/bin/tarsnap -xvf "$2" -C /mnt/kd "$3" echo; echo "Restoration of $3 complete"; echo else echo; echo "$3 was not restored"; echo fi ;; esac fi exit ----------------------- Regards Michael Knill On 30/9/18, 12:45 am, "Michael Keuter" <li...@mk...> wrote: > Am 29.09.2018 um 09:12 schrieb Michael Knill <mic...@ip...>: > > Hi Devs > > Im thinking that we should mention in the Tarsnap Online Backup doco about what needs to be done if you are restoring to a new box . > I think the process is as follows: > > • Build new Astlinux server > • Copy stored tarsnap.key to /mnt/kd/tarsnap > • tarsnap -xvf <archive> -C /mnt/kd to restore all files > • tarsnap –fsck to resync cache so you can backup again. If you don't you get: > tarsnap: Sequence number mismatch: Run --fsck > tarsnap: Error creating new archive > tarsnap: Error exit delayed from previous errors. I added the "tarsnap --fsck" part to our Wiki. And a link to the Action Script. > It may be worth also mentioning the process for restoring the database.dump file: > e.g. > echo; echo "Restoring database..." > echo "Shutting down Asterisk" > service asterisk stop >/dev/null > sleep 2 > sqlite3 /mnt/kd/astdb.sqlite3 'DROP TABLE IF EXISTS astdb;' >/dev/null > sqlite3 /mnt/kd/astdb.sqlite3 < /mnt/kd/database.dump >/dev/null > echo "Starting Asterisk" > service asterisk start >/dev/null > sleep 2 > > PS I am not a scripting expert so I probably have done some things the long way. > > What do you think? > > Regards > Michael Knill Michael http://www.mksolutions.info _______________________________________________ Astlinux-devel mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/astlinux-devel |