-
Notifications
You must be signed in to change notification settings - Fork 0
/
recover.sh
40 lines (31 loc) · 959 Bytes
/
recover.sh
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
#!/bin/bash
# Recover files from encrypted remote backup -- Linux version
# by Wolfram Rösler 2018-07-14
# Mount point for encrypted remote files (WebDAV mount)
ENC=/mnt/nextcloud-recovery
# Mount point for decrypted backup
DEC=/mnt/nextcloud-decrypted
# Encryption key file
export ENCFS6_CONFIG=/home/yourname/.encfs6.xml
# Make sure both mount points exist
mkdir -p $ENC || exit
mkdir -p $DEC || exit
# Umount first just to be sure
umount $DEC &>/dev/null
umount $ENC &>/dev/null
# Mount the encrypted files (rely on /etc/fstab to provide the
# mount options and /etc/davfs2/secrets to provide the log-on
# credentials)
mount $ENC || exit
# Decrypt
encfs --public --stdinpass $ENC/nextcloud/nextcloud-encrypted $DEC <<<'your encfs password' || exit
# Invoke a shell in the decrypted directory
(
cd $DEC || exit
pwd
echo "Press ^D to unmount the recovery files."
sudo -u $SUDO_USER -s
)
# Unmount everything
umount $DEC
umount $ENC