From cd32e794b00c04a5b969fd0292c7764e32e25863 Mon Sep 17 00:00:00 2001 From: TheMightyV Date: Sun, 2 Jan 2022 19:52:03 +0100 Subject: converted spaces to tabs, moved tar and bup backends to backend directory --- backends/bup.sh | 23 +++++++++++++++++++++++ backends/tar.sh | 14 ++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 backends/bup.sh create mode 100644 backends/tar.sh (limited to 'backends') diff --git a/backends/bup.sh b/backends/bup.sh new file mode 100644 index 0000000..83e4e98 --- /dev/null +++ b/backends/bup.sh @@ -0,0 +1,23 @@ +function create_bup_backup() { + BACKUP_DIR="mc-backups" + CUR_BACK_DIR="mc-backups/$CUR_YEAR" + + if [ ! -d "$CUR_BACK_DIR" ]; then + mkdir -p "$CUR_BACK_DIR" + fi + + bup -d "$CUR_BACK_DIR" index "$WORLD_NAME" + status=$? + if [ $status -eq 1 ]; then + bup -d "$CUR_BACK_DIR" init + bup -d "$CUR_BACK_DIR" index "$WORLD_NAME" + fi + + bup -d "$CUR_BACK_DIR" save -n "$BACKUP_NAME" "$WORLD_NAME" + + echo "Backup using bup to $CUR_BACK_DIR is complete" +} + +function ls_bup() { + bup -d "mc-backups/${CUR_YEAR}" ls "mc-sad-squad/$1" +} diff --git a/backends/tar.sh b/backends/tar.sh new file mode 100644 index 0000000..4d7ff36 --- /dev/null +++ b/backends/tar.sh @@ -0,0 +1,14 @@ +# TODO: Make default .tar with optional bup +function tar_create_backup() { + ARCHNAME="backup/$WORLD_NAME-backup_`date +%d-%m-%y-%T`.tar.gz" + tar -czf "$ARCHNAME" "./$WORLD_NAME" + + if [ ! $? -eq 0 ] + then + echo "TAR failed. No Backup created." + rm $ARCHNAME #remove (probably faulty) archive + return 1 + else + echo $ARCHNAME created. + fi +} -- cgit v1.2.3