restore function

This commit is contained in:
Michael Stanclift 2020-07-10 22:58:43 -05:00
parent 958aa017f8
commit a284d3b4d2
2 changed files with 34 additions and 10 deletions

View File

@ -3,7 +3,9 @@
## 2.1
### The Backup Release
A new function `./gravity-sync.sh backup` will now perform a sqlite operated backup of the `gravity.db` on the local Pi-hole.
A new function `./gravity-sync.sh backup` will now perform a sqlite operated backup of the `gravity.db` on the local Pi-hole. This can be run at any time you wish, but can also be automated by the `./gravity-sync.sh automate` function to run once a day. New and existing users will be prompted to configure both during this task. If can also disable both using the automate function, or just automate one or the other, by setting the value to `0` during setup.
By default, 7 days worth of backups will be retained in the `backup` folder. You can adjust the retention length by changing the `BACKUP_RETAIN` function in your `gravity-sync.conf` file. See the `ADVANCED.md` file for more information on setting these custom configuration options.
## 2.0
### The Smart Release

View File

@ -529,14 +529,36 @@ function smart_gs {
}
function restore_gs {
MESSAGE="This will restore ${GRAVITY_FI} on $HOSTNAME with the previous version!"
MESSAGE="This will restore your settings on $HOSTNAME with a previous version!"
echo_warn
MESSAGE="PREVIOUS BACKUPS"
echo_info
ls $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} | grep $(date +%Y) | grep ${GRAVITY_FI} | colrm 18
MESSAGE="Enter the date you want to restore from"
echo_need
read INPUT_BACKUP_DATE
if [ -f $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${GRAVITY_FI}.backup ]
then
MESSAGE="Backup File Located"
echo_info
else
MESSAGE="Invalid Requested"
fi
intent_validate
MESSAGE="Stopping Pi-hole Services"
echo_stat
sudo service pihole-FTL stop >/dev/null 2>&1
error_validate
MESSAGE="Restoring ${GRAVITY_FI} on $HOSTNAME"
echo_stat
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${GRAVITY_FI}.backup ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Validating Ownership on ${GRAVITY_FI}"
@ -579,11 +601,11 @@ function restore_gs {
if [ "$SKIP_CUSTOM" != '1' ]
then
if [ -f $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup ]
if [ -f $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${CUSTOM_DNS}.backup ]
then
MESSAGE="Restoring ${CUSTOM_DNS} on $HOSTNAME"
echo_stat
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
@ -630,16 +652,16 @@ function restore_gs {
echo_info
sleep 1
MESSAGE="Restarting FTLDNS Services"
echo_stat
sudo service pihole-FTL start >/dev/null 2>&1
error_validate
MESSAGE="Updating FTLDNS Configuration"
echo_stat
${PIHOLE_BIN} restartdns reloadlists >/dev/null 2>&1
error_validate
MESSAGE="Reloading FTLDNS Services"
echo_stat
${PIHOLE_BIN} restartdns >/dev/null 2>&1
error_validate
logs_export
exit_withchange
}