FAQ 33: How to backup your Synology database
The recommended method of backing up PMS is to use Hyper Backup where the entire server’s files plus their ownership, permissions, including date/time stamp is preserved
This FAQ applies to those who want to backup only the databases.
- Create a scheduled task → User Script
- It must run as user: root
- It emails you the results so you have confirmation
- Set the ‘Dest’ folder (keep within quotes) to where you want the backup to go.
- The body of the script is as follows:
#!/bin/sh
# Set destination (Set this value)
Dest="/volume1/My Shared Folder"
# Stop Plex
synopkg stop PlexMediaServer
Result=$?
if [ $Result -ne 0 ]; then
echo ERROR $Result when stopping PlexMediaServer.
echo Backup aborted.
exit 1
fi
# Dest exists ?
[ ! -w "$Dest" ] && echo ERROR: Cannot write to '$Dest' && exit 2
# Get into the databases directory (this is now volume independent)
cd "/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData/Plex Media Server/Plug-in Support/Databases"
# Create filename using Date/Time (yyyy-mm-dd_hh-mm)
# Backup
tar cvzf "$Dest/Plex-Database-Backup_$(date +%Y-%m-%d_%H-%M).tar.gz" .
Result=$?
# Check result
[ $Result -ne 0 ] && echo ERROR Got exit code $Result from tar. Please check && exit
# Restart Plex
synopkg start PlexMediaServer