From b84012312965bd68816e9c362b945773b09acacc Mon Sep 17 00:00:00 2001 From: Patrick Hamers Date: Mon, 5 Jul 2021 13:00:08 +0200 Subject: [PATCH] Create snapshot_move.sh --- snapshot_move.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 snapshot_move.sh diff --git a/snapshot_move.sh b/snapshot_move.sh new file mode 100644 index 0000000..64b3e2c --- /dev/null +++ b/snapshot_move.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Usage: snapshot_move.sh +# This script moves the snapshot file to the root of the webserver +# The old snapshot will be available as 'snapshot_old.tar.xz" + +# VARS: +SNAPSHOTSOURCEFILE="/tmp/snapshot.tar.xz" +SNAPSHOTDESTFILE="/var/www/html/snapshot.tar.xz" +SNAPSHOTOLDFILE="/var/www/html/snapshot_old.tar.xz" + +[[ ! -f $SNAPSHOTSOURCEFILE ]] && { echo "No snapshot found, nothing to move" ; exit 1; } + +if [[ -f $SNAPSHOTOLDFILE ]]; then + rm -rf $SNAPSHOTOLDFILE +fi + +mv $SNAPSHOTDESTFILE $SNAPSHOTOLDFILE + +mv $SNAPSHOTSOURCEFILE $SNAPSHOTDESTFILE + +chown root:root $SNAPSHOTDESTFILE + +exit 0