-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbwbackup.sh
More file actions
executable file
·33 lines (33 loc) · 1.18 KB
/
Copy pathbwbackup.sh
File metadata and controls
executable file
·33 lines (33 loc) · 1.18 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
29
30
31
32
33
cd ~/Github
# Sourcing environment variables stored in direnv
source ~/Github/.envrc
# Setting up filename for .csv file
export FILENAME=.bwbackup-$(date +%m-%d-%Y-%H-%M-%S)
# Opening the encrypted partition
echo $DEVICEPASSWORD | sudo cryptsetup open /dev/nvme0n1p3 bwbackup
# Mounting the partition
sudo mount /dev/mapper/bwbackup /bwbackup
# Sourcing local variables
source /bwbackup/.env_vars.txt
# Creating temporary directory
mkdir ~/.bitwarden
# Exporting passwords
echo $BITPASS | bw export --output ~/.bitwarden/$FILENAME.csv
# Changing directory to temp directory
cd ~/.bitwarden
# Compressing the file with password protection
sudo zip -P "$ZIPASS" ~/.bitwarden/$FILENAME.zip $FILENAME.csv
# Copying the file to encrypted partition
sudo cp ~/.bitwarden/$FILENAME.zip /bwbackup/$FILENAME.zip
# Copying the file to cloud storage
cp ~/.bitwarden/$FILENAME.zip ~/OneDrive/Bitwarden-Backup/$FILENAME.zip
# Shredding the files
sudo shred -uz -n5 ~/.bitwarden/$FILENAME.zip
sudo shred -uz -n5 ~/.bitwarden/$FILENAME.csv
# Unmounting partition
sudo umount /bwbackup
# Removing temp dir
sudo rm -rf ~/.bitwarden
# Closing encrypted partition
sudo cryptsetup close bwbackup
cd