-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup_script.sh
More file actions
executable file
·28 lines (22 loc) · 1.02 KB
/
backup_script.sh
File metadata and controls
executable file
·28 lines (22 loc) · 1.02 KB
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
#!/bin/bash
# this file is the driver of backing up the production directory.
# the script initiates the backup and calls other scripts to perform various
# operations that are necessary for our system.
# the script is currently set to run once per day.
# USAGE: ./backup_script.sh
# set environment variables, and get the date for the snapshot name
source /home/localadmin/.aws_env
date="$(date '+%d%b%Y-%H-%M')" || exit 1
# take the snapshot of our production directory and place it within the
# snapshot directory with an appropriate name
btrfsSnapshotCreate()(
sudo btrfs subvolume snapshot /mnt/btrfs_project_drive/production \
/mnt/btrfs_project_drive/snapshots/"$date"
)
btrfsSnapshotCreate
# perform deduplicaiton via file hashes
python3 /home/localadmin/ESA-project/hash_dedup.py "$date"
# upload the snapshotted files to s3
python3 /home/localadmin/ESA-project/upload_to_s3.py "$date"
# delete the snapshot directory from local drive
sudo rm -r /mnt/btrfs_project_drive/snapshots/"$date"