blob: 285f525e51f7205af7f3d555660c84debb21bfc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|