blob: ee58d2f18f5db5bfcb91ecbcaf3c342b0c30abc8 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/bash
#
# This configuration file was auto-generated by the Puppet configuration
# management system. Any changes you make to this file will be overwritten
# the next time Puppet runs. Please make configuration changes to this
# service in Puppet.
#
# TODO: custom log file
BACKUP_FOLDER="<%= directory %>"
FULL_IF_OLDER_THAN="<%= full_if_older_than %>"
REMOVE_OLDER_THAN="<%= remove_older_than %>"
ENCRYPT_KEY="<%= encryptkey %>"
SIGN_KEY="<%= encryptkey %>"
<% backup_exclude_unencrypted.each do |del| -%>
EXCLUDE="$EXCLUDE --exclude <%= del %>"
<% end -%>
<% backup_include_unencrypted.each do |add| -%>
INCLUDE="$INCLUDE --include <%= add %>"
<% end -%>
# some systems have a limited /tmp folder
TMP="/var/tmp"
mkdir -p $TMP
export PASSPHRASE='<%= password %>'
mkdir -p $BACKUP_FOLDER
# adds support for checking the existing backup
if [ "$1" == "--check" ]; then
duplicity collection-status file:///$BACKUP_FOLDER
else
# it's important to let $EXCLUDE come before $INCLUDE to
# have greater precedence; see duplicity(1) for more info
duplicity -v6 --full-if-older-than $FULL_IF_OLDER_THAN \
--tempdir $TMP --encrypt-key $ENCRYPT_KEY --sign-key $SIGN_KEY \
--exclude $TMP $EXCLUDE $INCLUDE --exclude '**' / file:///$BACKUP_FOLDER
if [ "$?" != "0" ]; then
fatal "Duplicity backup failed."
fi
duplicity remove-older-than $REMOVE_OLDER_THAN file:///$BACKUP_FOLDER --force || exit 1
if [ "$?" != "0" ]; then
fatal "Removal of old backups failed."
fi
fi
|