aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2015-03-20 01:32:42 +0100
committerDavid Runge <dave@sleepmap.de>2015-03-20 01:32:42 +0100
commitfd3b4a68b7ba29e77a3147f8e5fced19eeb294d4 (patch)
tree3b5defaf2962d876408ed576c5a8bc708ff4b4f5 /scripts
parent5173d02e1fc5b4de0f6e315272d9011ffa13194b (diff)
downloadcrypted-backups-fd3b4a68b7ba29e77a3147f8e5fced19eeb294d4.tar.gz
crypted-backups-fd3b4a68b7ba29e77a3147f8e5fced19eeb294d4.tar.bz2
crypted-backups-fd3b4a68b7ba29e77a3147f8e5fced19eeb294d4.tar.xz
crypted-backups-fd3b4a68b7ba29e77a3147f8e5fced19eeb294d4.zip
backup-websites: Adding first version of backup-websites script, service and timer.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/backup-websites32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/backup-websites b/scripts/backup-websites
new file mode 100755
index 0000000..285f525
--- /dev/null
+++ b/scripts/backup-websites
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Backup websites
+
+timestamp="$(date +"%Y%m%d-%H%M%S")-"
+
+# If the backup location doesn't exist yet, create it
+if [ ! -d $website_folder_destination ]; then
+ mkdir -p $website_folder_destination
+fi
+
+# If the parent directory of the backup source exists, enter it
+if [ -d $website_folder_source ]; then
+ cd $website_folder_source
+else
+ exit 1
+fi
+
+for subfolder in $website_folder_source*
+do
+ subfolder=$(basename $subfolder)
+ echo "$subfolder --> $website_folder_destination$timestamp$subfolder$tar_suffix$gpg_suffix"
+ # tar to /tmp
+ tar cfJ "$tmp$timestamp$subfolder$tar_suffix" $subfolder
+ # gpg to backup location
+ gpg -e \
+ -r "$gpg_public_key" \
+ -o "$website_folder_destination$timestamp$subfolder$tar_suffix$gpg_suffix" \
+ $tmp$timestamp$subfolder$tar_suffix
+ # remove tar in /tmp
+ rm -f $tmp$timestamp$subfolder$tar_suffix
+done
+