Automate OBS Studio Scene Backup on Linux
This guide explains how to automate the backup of your active OBS Studio scene collections on a Linux operating system using a custom Bash shell script. You will learn where OBS stores its scene configuration files, how to write a script to copy and compress these files, and how to schedule the script to run automatically using Cron.
Step 1: Locate Your OBS Scene Collections
On Linux, OBS Studio stores its user configuration data, including scene collections, in your home directory.
The path to the active scene collections (saved as .json
files) is:
~/.config/obs-studio/basic/scenes/Step 2: Create the Backup Shell Script
You can write a simple Bash script that packages these JSON files into a timestamped compressed archive.
Create a new script file in your terminal:
nano ~/backup_obs_scenes.shPaste the following script into the file:
#!/bin/bash # Define source and backup directories SOURCE_DIR="$HOME/.config/obs-studio/basic/scenes" BACKUP_DIR="$HOME/Backups/OBS_Scenes" TIMESTAMP=$(date +"%Y%m%d_%H%M%S") BACKUP_FILE="$BACKUP_DIR/obs_scenes_$TIMESTAMP.tar.gz" # Create the backup directory if it does not exist mkdir -p "$BACKUP_DIR" # Check if the source directory exists and backup if [ -d "$SOURCE_DIR" ]; then tar -czf "$BACKUP_FILE" -C "$SOURCE_DIR" . echo "Backup completed successfully: $BACKUP_FILE" else echo "Error: OBS Studio scenes directory not found." >&2 exit 1 fiSave and close the file (in nano, press
Ctrl+O,Enter, thenCtrl+X).
Step 3: Make the Script Executable
Before running the script, you must grant it execution permissions. Run the following command in your terminal:
chmod +x ~/backup_obs_scenes.shYou can test the script manually by running:
./backup_obs_scenes.shThis will create a .tar.gz file inside a new
Backups/OBS_Scenes folder in your home directory.
Step 4: Automate the Backup Using Cron
To automate this process so that backups occur without manual intervention, schedule the script using the system’s cron daemon.
Open the crontab editor:
crontab -eAdd a line at the bottom of the file to schedule the script. For example, to run the backup every day at 2:00 AM, add:
0 2 * * * /bin/bash /home/YOUR_USERNAME/backup_obs_scenes.shNote: Replace
YOUR_USERNAMEwith your actual Linux username.Save and exit the editor. The cron daemon will now automatically back up your OBS Studio scene collections daily.