-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbackup_plex_dbs
25 lines (17 loc) · 915 Bytes
/
backup_plex_dbs
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
#!/bin/bash
# Set Appdata Directory (must include trailing /)
plexdbDirectory='/PATH/TO/YOUR/PLEX/DATABASES/DIRECTORY/'
# Set Backup Directory (must include trailing /)
backupDirectory='/PATH/TO/YOUR/BACKUP/DIRECTORY/'
# Set Number of Days to Keep Backups
days=365
#--START SCRIPT--#
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "Plex DB Backup" -d "Backup of Plex DB's starting."
docker stop plex
cp -a "$plexdbDirectory"com.plexapp.plugins.library.db "$backupDirectory"com.plexapp.plugins.library-$(date +"%Y-%m-%d@%H.%M").db
cp -a "$plexdbDirectory"com.plexapp.plugins.library.blobs.db "$backupDirectory"com.plexapp.plugins.library.blobs-$(date +"%Y-%m-%d@%H.%M").db
docker start plex
#Cleanup Old Backups
find "$backupDirectory"* -type d -mtime +"$days" -exec rm -rf {} +
#Stop Notification
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "Plex DB Backup" -d "Backup of Plex DB's complete."