From 29070651d34d5ec30e9eeea8b4ca3d04c9d649f9 Mon Sep 17 00:00:00 2001 From: None Date: Wed, 5 Jul 2017 21:07:57 -0400 Subject: [PATCH] .tar file was not actually being gzip'd. Config file changed to specify $FNAME_BASE without an extension. --- config/user-data/edgerouter-backup.conf | 4 +++- config/user-data/hooks/03-edgerouter-backup.sh | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/user-data/edgerouter-backup.conf b/config/user-data/edgerouter-backup.conf index ecdaaa7..6065b82 100644 --- a/config/user-data/edgerouter-backup.conf +++ b/config/user-data/edgerouter-backup.conf @@ -20,4 +20,6 @@ FNAME_BASE=$HOSTNAME FNAME_CONFIG=$FNAME_BASE.config.conf FNAME_CLI=$FNAME_BASE.commands.conf -FNAME_BACKUP=$FNAME_BASE.backup.tar.gz \ No newline at end of file + +# Base filename, no extension! +FNAME_BACKUP=$FNAME_BASE.backup diff --git a/config/user-data/hooks/03-edgerouter-backup.sh b/config/user-data/hooks/03-edgerouter-backup.sh index ef33ac9..e298294 100644 --- a/config/user-data/hooks/03-edgerouter-backup.sh +++ b/config/user-data/hooks/03-edgerouter-backup.sh @@ -26,21 +26,21 @@ GIT_COMMIT_MSG="$COMMIT_CMT | by $USER | via $COMMIT_VIA | $TIME" # Remove temporary files #echo "edgerouter-backup: Removing temporary files" -sudo rm /tmp/edgerouter-backup-$FNAME_CONFIG &> /dev/null -sudo rm /tmp/edgerouter-backup-$FNAME_CLI &> /dev/null -sudo rm /tmp/edgerouter-backup-$FNAME_BACKUP &> /dev/null +sudo rm /tmp/edgerouter-backup-$FNAME_CONFIG &> /dev/null +sudo rm /tmp/edgerouter-backup-$FNAME_CLI &> /dev/null +sudo rm /tmp/edgerouter-backup-$FNAME_BACKUP.tar &> /dev/null # Generate temporary config files sudo cli-shell-api showConfig --show-active-only --show-ignore-edit --show-show-defaults > /tmp/edgerouter-backup-$FNAME_CONFIG sudo cli-shell-api showConfig --show-commands --show-active-only --show-ignore-edit --show-show-defaults > /tmp/edgerouter-backup-$FNAME_CLI -sudo find /config/* | grep -v "/config/dhcpd.leases" | xargs tar cf /tmp/edgerouter-backup-$FNAME_BACKUP &> /dev/null +sudo find /config/* | grep -v "/config/dhcpd.leases" | xargs tar cf /tmp/edgerouter-backup-$FNAME_BACKUP.tar &> /dev/null # Push config files echo "edgerouter-backup: Copying backup files to $SSH_USER@$SSH_HOST:$REPO_PATH" sudo scp -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CONFIG $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CONFIG > /dev/null sudo scp -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CLI $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CLI > /dev/null -sudo cat /tmp/edgerouter-backup-$FNAME_BACKUP | sudo ssh -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "gzip -cnq9 > $REPO_PATH/$FNAME_BACKUP" > /dev/null +sudo cat /tmp/edgerouter-backup-$FNAME_BACKUP.tar | sudo ssh -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "gzip -cnq9 > $REPO_PATH/$FNAME_BACKUP.tar.gz" > /dev/null # git commit and git push on remote host echo "edgerouter-backup: Triggering 'git commit'" @@ -48,9 +48,9 @@ sudo ssh -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChec cd $REPO_PATH git add $REPO_PATH/$FNAME_CONFIG git add $REPO_PATH/$FNAME_CLI -git add $REPO_PATH/$FNAME_BACKUP +git add $REPO_PATH/$FNAME_BACKUP.tar.gz git commit -m "$GIT_COMMIT_MSG" git push ENDSSH -echo "edgerouter-backup: Complete" \ No newline at end of file +echo "edgerouter-backup: Complete"