Effortlessly set up automatic backups and automatic optimizations of DaVinci Resolve's PostgreSQL databases
Here are some workflow tools designed for macOS or Linux systems that are running as PostgreSQL servers for DaVinci Resolve.
This repository includes:
- For macOS Ventura:
- A
bash
script that will let you effortlessly create, load, and startlaunchd
daemons that will automatically backup and automatically optimize your PostgreSQL 13 databases - A
bash
script to uninstall the above tools
- A
- For Red Hat Enterprise Linux 9:
- A
bash
script that will let you effortlessly create and startsystemd
units and timers that will automatically backup and automatically optimize your PostgreSQL 13 databases - A
bash
script to uninstall the above tools
- A
Download the macos-install.sh
file and execute the script with sudo
permissions:
sudo sh macos-install.sh
The script will then:
- Prompt you for the name of your PostgreSQL database;
- Prompt you for the path of the folder where your backups will go;
- Prompt you for how often you want to back the database up, in seconds; and
- Prompt you for how often you want to optimize the database, in seconds.
Once you run through this script, you will be automatically backing up and optimizing your database according to whatever parameters you entered.
The script creates macOS launchd
daemons, so these automatic backups and automatic database optimizations will continue on schedule, even after the system is rebooted. It's neither necessary nor desirable to run the script more than once per individual Resolve database.
To verify that everything is in working order, you can periodically check the log files located in /Users/Shared/DaVinci-Resolve-PostgreSQL-Workflow-Tools/logs/
.
macOS Ventura's default shell is zsh
. However, these scripts' shebangs still specify the use of bash
, which has still been included since the switch from back in macOS Catalina. The scripts do not use any incompatible word splitting or array indices, so the scripts should be easily converted to native zsh
in future releases of macOS. For more information, see Scripting OS X.
From an administrative user account, download the enterprise-linux-install.sh
file and then execute the script:
sudo sh enterprise-linux-install.sh
The script will then:
- Prompt you for the name of your PostgreSQL database;
- Prompt you for the path of the folder where your backups will go;
- Be sure to use the absolute path
- Prompt you for how often you want to back the database up; and
- Be sure to use
systemd
notation like1h
or3h
or1d
, etc.
- Be sure to use
- Prompt you for how often you want to optimize the database.
- Be sure to use
systemd
notation like1h
or3h
or1d
, etc.
- Be sure to use
Once you run through this script, you will be automatically backing up and optimizing your database according to whatever parameters you entered.
The script creates systemd
units and timers, so these automatic backups and automatic database optimizations will continue on schedule, even after the system is rebooted. It's neither necessary nor desirable to run the script more than once per individual Resolve database.
To verify that everything is in working order, you can periodically check the log files located in /usr/local/DaVinci-Resolve-PostgreSQL-Workflow-Tools/logs
.
This script has been tested and works for PostgreSQL 13 servers for:
- DaVinci Resolve 18
- macOS Ventura
- EnterpriseDB PostgreSQL 13, as included from Blackmagic Design's DaVinci Resolve Project Server app
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- PostgreSQL 13 from the PostgreSQL Yum Repository
Beginning with DaVinci Resolve 18, the Project Manager window, as well as the Project Server GUI app refer to "project libraries." These are just individual PostgreSQL databases, referred to in previous versions of DaVinci Resolve as "databases." These scripts refer to the names of "databases" you want to back up and optimize.
Jathavan Sriram wrote a great article back in 2014 about how to use pgAdmin III tools in bash
, instead of having to use the psql
shell.
The core insights from his 2014 article still apply, but several crucial changes need to be made for modern systems:
- Apple deprecated
cron
in favor oflaunchd
. - From DaVinci Resolve 12.5.4 through 17, DaVinci Resolve used PostgreSQL 9.5. For DaVinci Resolve 18 an onward, PostgreSQL 13 is recommended.
- The locations of the
pg_dump
,reindexdb
, andvacuumdb
binaries in PostgreSQL 13 are different from what they were in PostgreSQL 8.4 and 9.5.
On macOS, this script creates and installs bash
scripts and launchd
daemons that, together, regularly and automatically backup and optimize the PostgreSQL databases that DaVinci Resolve uses.
On Red Hat Enterprise Linux, this script creates and installs bash
scripts, systemd
units, and systemd
timers that, together, regularly and automatically backup and optimize the PostgreSQL databases that DaVinci Resolve uses. After a reboot, each systemd
timer will be delayed by a random number of seconds, up to 180 seconds, so as to stagger the database utilities for optimal performance.
The .pgpass
file that the script creates assumes that the password for your PostgreSQL database is DaVinci
, which is a convention from Blackmagic Design.
Make sure that you create the directory where your backups are going to go before running the script.
If you have any spaces in the full path of the directory where your backups are going, be sure to escape them with \
when you run the script.
The script can be run from any admin user so long as it's run with sudo
so as to have root
user permissions.
Because the script generates launchd
daemons, the backups and optimizations will occur if the machine is running, even without any user being logged in.
The .pgpass
file that the script creates assumes that the password for your PostgreSQL database is DaVinci
, which is a convention from Blackmagic Design.
Make sure that you create the directory where your backups are going to go before running the script.
Be sure to use the absolute path for the directory into which the backups will go.
The script can be run from any admin user so long as it's run with sudo
so as to have root
user permissions.
The *.backup
files that this script generates can be restored into a new, totally blank PostgreSQL database in the event of a disk failure. These *.backup
files are also handy even just to migrate entire databases from one PostgreSQL server to another.
In the event of a disk failure hosting the PostgreSQL database, the procedure to restore from these *.backup
files to a new PostgreSQL server is as follows:
-
Set up a new, totally fresh PostgreSQL server
-
Create a fresh PostgreSQL database on the server, naming your database whatever you want it to be named
- If the version of Resolve you're using is the same version you were using when the
*.backup
file was created, you can just connect your client workstation and create a new blank database via the GUI; - But if your
*.backup
file was created for some earlier version of Resolve, you'll need to become thepostgres
user withroot
permissions and create a completely blank database:$ sudo su - postgres $ createdb <newdatabasename>
- If the version of Resolve you're using is the same version you were using when the
-
Run the command:
$ pg_restore --host localhost --username postgres --password --single-transaction --clean --if-exists --dbname=<dbname> <full path to your backup file>
You'll need to enter the password for the
postgres
user. This is the password for the PostgreSQL database userpostgres
, not the OS user. -
If the version of Resolve you're using is the same version you were using when the
*.backup
file was created, you should be good to go, but if your*.backup
file was created for some earlier version of Resolve, you should now be able to connect the the database via the GUI on the client and then upgrade it for your current version.
If you wish to stop automatically backing up and optimizing a particular database, you can run macos-uninstall.sh
:
sudo sh macos-uninstall.sh
The script will ask you what database you want to stop backing up and optimizing. The database you specify will then stop being backed up, stop being optimized, and all relevant files will be safely and cleanly removed from your system. The database itself, as well as the backup files that have already been generated, will remain untouched.
If you wish to stop automatically backing up and optimizing a particular database, you can run enterprise-linux-uninstall.sh
:
sudo sh enterprise-linux-uninstall.sh
The script will ask you what database you want to stop backing up and optimizing. The database you specify will then stop being backed up, stop being optimized, and all relevant files will be safely and cleanly removed from your system. The database itself, as well as the backup files that have already been generated, will remain untouched.