ebd4b8f46430b732fe5608849317a21d89f8ef4d
[feisty_meow.git] / scripts / archival / backup_arbitrary.sh
1 #!/bin/bash
2
3 # backs up a specific single directory by making an archive of it (tar.gz).
4 # the storage location for the created archive is also specified.
5
6 target_asset_path="$1"; shift
7 archive_storage_path="$1"; shift
8 archive_tag="$1"; shift
9
10 if [ -z "$target_asset_path" -o -z "$archive_storage_path" ]; then
11   echo Backups up a directory by creating a compressed archive of it in a storage
12   echo location.
13   echo Requires the path to the folder that will be backed up as the first parameter
14   echo and the path to the archive storage directory as the second parameter.
15   exit 1
16 fi
17
18 # use a default archive tag if there was none provided.
19 if [ -z "$archive_tag" ]; then
20   archive_tag=folder
21 fi
22
23 sep='_'
24
25 tar -czf "${archive_storage_path}/${archive_tag}_bkup_$(date +"%Y$sep%m$sep%d$sep%H%M$sep%S" | tr -d '/\n/').tar.gz" "$target_asset_path" &>>$TMP/zz_arbitrary_backups.log
26
27