SnapShooter is a cloud backup and recovery solution. Use SnapShooter to back up servers, volumes, databases, and applications from DigitalOcean and other cloud providers.
You can write scripts to perform actions before and after SnapShooter backup jobs, like closing a file-based database before a backup and reopening it after the backup.
Pre- and post-backup scripts must meet the following requirements:
Scripts must be located on the server. When you create a backup job for the server, you specify the path on the server to any scripts.
Scripts must be executable. You can set the file as executable with chmod +x path/to/script
, substituting in the path to the script. SnapShooter skips scripts that are not executable.
Scripts must start with a shebang interpreter directive. For example, #!/bin/bash
for bash scripts, #!/usr/bin/env perl
to use the env
command to find the path to the Perl executable, or #!/usr/bin/python
for Python scripts.
Scripts must not take longer than five minutes to run. If a script takes more than five minutes, the backup times out and your script may stop mid-execution.
SnapShooter pre- and post-backup scripts are available for Business and Agency plans.
SnapShooter does not support pre- or post-backup scripts for AWS compute or serverless.
Scripts can access the following environment variables from SnapShooter:
$WORKING_DIR
, which is the current folder SnapShooter is using for backups. This is a good place to store any temporary files.
$SNAPSHOOTER_BACKUP_ID
, which is the backup ID.
If the script creates temporary files, SnapShooter does not clean them up. SnapShooter does clean up all working directories over two days old to avoid filling the server with logs.
If the pre-backup script exits with a non-zero exit code, the backup job skips all steps and registers as failed. If there is a post-backup script, SnapShooter attempts to run it before finishing.
If the post-backup script fails, the backup registers as a success with an error.