-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathee-br-backup
91 lines (51 loc) · 1.67 KB
/
ee-br-backup
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Set bash environment error management
set -e
set -u
# Source local functions file
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $script_dir/functions
# Check for root user runtime
check_root
################################################################################
# Source openspace functions file
source_os_functions
################################################################################
os-log_script
################################################################################
os-define_formatting
define_vars
os-read_conf_settings
################################################################################
purge_incomplete_archives
purge_dirs
create_dirs backup
update_storage_info
purge_backups
backup_locally
echo "${b}Now compressing backup...${x}"
echo
cd $tmp_dir
### Tar.bz2 this backup archive.
tar cSf - $backup_name -P | pv -s $(du -sb $backup_name | awk '{print $1}') | bzip2 > $backups_archive_dir/$backup_name.tar.bz2.incomplete
mv $backups_archive_dir/$backup_name.tar.bz2.incomplete $backups_archive_dir/$backup_name.tar.bz2
echo
echo "${g}${b}Finished compressing backup and stored in | $backups_archive_dir/ | ${x}"
echo
################################################################################
if [ "$backup_location" = "s3" ]
then
mv "$tmp_backup_dir"/* "$backups_latest_dir"
########################################################################
restore_from_S3 test
########################################################################
backup_to_S3
else
rm -r "$tmp_backup_dir"
fi
if [ -d $tmp_dir ]
then
rm -r ${tmp_dir:?}
fi
echo "${g}${b}Backup complete!${x}"
echo