Backup Custom Scripts

Set up and use custom scripts for pre and/or post backup operations.

Custom scripts in Simplebackups allow you to extend the functionality of your backup process. This documentation will guide you through setting up and using custom scripts for pre and/or post backup operations. The examples provided will be written in Bash and demonstrate how to call a Python script.

Requirements:

  • Access to your own server.
  • Basic knowledge of Bash scripting.
  • Python installed on your server.
 

1. Preparing Your Server: Ensure that your server meets the requirements mentioned above. Make sure Python is installed, and the path to the Python binary is defined in your environment.

 

2. Writing Bash Scripts:

a. Pre-Backup Script: Create a Bash script that you want to run before the backup. Here's a simple example:

#!/bin/bash

# Your pre-backup operations go here
echo "Executing pre-backup operations..."
 

b. Post-Backup Script: Create another Bash script for post-backup operations. Here's an example:

#!/bin/bash

# Your post-backup operations go here
echo "Executing post-backup operations..."

3. Calling a Python Script:

 

Integrating Python Script: Assuming you have a Python script named example.py, insert the following code to your pre backup script.

#!/bin/bash

# Define Python binary path
PYTHON_PATH="/usr/bin/python3"

# Your Python script
$PYTHON_PATH /path/to/your/example.py
 

Run a test backup to ensure that your custom scripts are executed successfully before and/or after the backup job.

 

Remember to adapt the paths and commands according to your server setup and the location of your scripts. If you encounter any issues, refer to SimpleBackups documentation or reach out to support.

 
Did this answer your question?
😞
😐
🤩

Last updated on February 26, 2024