-
Notifications
You must be signed in to change notification settings - Fork 1
/
backuppc-remove.sh
48 lines (36 loc) · 1008 Bytes
/
backuppc-remove.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
41
42
43
44
45
46
47
#!/bin/bash
# Remove Data from backups in BackupPC 3.x (might work with 4.x?) for a variety
# of purposes such as right to be forgotten under EU GDPR.
#
# Requirements:
# 1. Binaries: /usr/bin/pigz, /usr/bin/unpigz, /usr/bin/rename
# 2. Set Constants to match your data and paths
#
# Note: Run at your own risk
#
# Graham Smith (gsmitheidw), November 2018.
#
#
# Constants
userdata='username'
pcpath='/var/lib/backuppc/pc/pc-name'
datadir='fdDrive/fHomeDir'
cd $pcpath
# Delete from Backups:
# For all backup folders
for backupdirs in */; do
rm -rf $pcpath/$backupdirs/$datadir/$userdata
done
# Delete from Logs:
for filename in XferLOG.*.z; do
unpigz $filename
done
# Remove lines mentioning criteria, case insensitive, inline
echo "Removing lines matching criteria"
sed -i '/f$studentnum/dI' XferLOG.*
# Re-compress logs
echo "Re-compressing logs.."
pigz -n -z `ls XferLOG.*`
# restore the original file extension:
rename 's/\.zz$/\.z/' XferLOG.*
echo "Operation complete!"