DCImanager 6 Knowledge Base

How to configure automatic backups with bash script?

This article describes an alternative way to automate platform backups. To configure the backup schedule through the platform interface, see the documentation article Creating platform backups.

Example

On the server with DCImanager 6:

  1. Create the script /root/dci_backup.sh:

    Script option with saving the backup to a local server
    #!/bin/bash
    yes "" | dci backup > backup.log 2>&1
    cat backup.log | awk -F'tar cfvz' '{print $2}' | egrep -o '[a-zA-Z0-9/_\.]+' | head -n1
    rm -f backup.log
    Script option with saving the backup to a local and an external server
    #!/bin/bash
    backup=$(yes "" | dci backup > backup.log 2>&1;cat backup.log | awk -F'tar cfvz' '{print $2}' | egrep -o '[a-zA-Z0-9/_\.]+' | head -n1;rm -f backup.log)
    rsync $backup user@domain.com:/backups/
    Comments
  2. Make the script executable:

    chmod +x /root/dci_backup.sh
  3. Add the start of this script to cron:

    Example of daily script start at 02:15
    echo "15 2 * * * /root/dci_backup.sh" | crontab
  4. Restart cron:

    systemctl restart crond