-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.sh
More file actions
32 lines (24 loc) · 852 Bytes
/
backup.sh
File metadata and controls
32 lines (24 loc) · 852 Bytes
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
# create simple backups with borg .. this command is used mainly as reference
# or starting point to write a more complete automated backup script.
# WARNING: this does not use encryption or authentication!
if iscommand borg && ! iscommand backup; then
backup() {
set -u -o pipefail
repo="${1:?repository path required}";
name="$(uuidgen)";
shift 1;
# init if repo does not exist / is empty directory
if ! [[ -e $repo ]] || [[ -z $(ls -A "$repo") ]]; then
mkdir -p "$repo"
borg init --append-only --encryption none "$repo" \
|| return $?;
fi
# check if this is indeed a borg repo
borg info "$repo" >/dev/null \
|| return $?;
# create new backup
borg create --compression zstd --stats --progress "$repo::$name" "$@" \
|| return $?;
}
fi