-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbackup_plexdata
31 lines (21 loc) · 1.03 KB
/
backup_plexdata
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
#!/bin/bash
#--DEFINE VARIABLES--#
# Set Plexdata Directory (must include trailing /)
plexdataDirectory='/PATH/TO/YOUR/PLEXDATA/'
# Set Backup Directory (must include trailing /)
backupDirectory='/PATH/TO/YOUR/BACKUP/DIRECTORY/'
# Set Number of Days to Keep Backups
days=45
#--START SCRIPT--#
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "Plexdata Backup" -d "Backup of Plexdata starting."
now="$(date +"%Y-%m-%d"@%H.%M)"
mkdir ""$backupDirectory""$now""
#Plexdata Backup (excluding Transcode directory from backups)
cd ""$backupDirectory""$now""
tar -cf plexdata-"$now".tar --exclude "$plexdataDirectory"Transcode "$plexdataDirectory"
#Uncomment below line to use pigz to compress the file afterwards and delete the original .tar file (will use max CPU threads unless otherwise specified with -p#)
#pigz -9 plexdata-"$now".tar
#Cleanup Old Backups
find "$backupDirectory"* -type d -mtime +"$days" | xargs rm -rf
#Stop Notification
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "Plexdata Backup" -d "Backup of Plexdata complete."