Mitto CMD job that backs up all job configs

You can easily make a cmd job that will back up your job configs (stored in /var/mitto/conf)

Create a new cmd job and enter the following commands:

exec 1>/var/mitto/data/log-backup.txt 2>&1
mkdir -p /var/mitto/data/backup_`date --date=today +%Y_%m_%d`
cp /var/mitto/conf/*.json /var/mitto/data/backup_`date --date=today +%Y_%m_%d`/
zip -j -r /var/mitto/data/backup_`date --date=today +%Y_%m_%d`.zip /var/mitto/data/backup_`date --date=today +%Y_%m_%d`/*
rm -rfv /var/mitto/data/backup_`date --date=today +%Y_%m_%d`/

Running the job will create a zip file named backup_{today's date}.zip in the files page. It will also write to a log file visible using the mitto api at: https://{MITTO_URL}/api/v2/files/log-backup.txt

NOTE: If you see an error about zip not being found, you will need to have zip installed.

Taking this a step further, consider the following job:

{
  shell: true
  cmd:
    '''
    mkdir -p /var/mitto/data/mitto-backup
    /usr/sbin/mitto backup /var/mitto/data/mitto-backup/backup_mitto$(date '+%Y-%m-%d').tgz
    /usr/bin/pg_dump -U mitto analytics > /var/mitto/data/mitto-backup/backup_analytics$(date '+%Y-%m-%d').sql
    tar -czvf /var/mitto/data/mitto-backup$(date '+%Y-%m-%d').tgz /var/mitto/data/mitto-backup
    rm -rf /var/mitto/data/mitto-backup
    '''
  exec: false
  timeout: null
  cmd_env: {
    LANG: C.UTF-8
  }
}

This job actually creates a backup file we can restore a Mitto from in the event of a disaster. This backup includes all jobs and data from the Mitto database. Further, this job will back up the customer data from the analytics database, then pack up both in a tar ball.

This job can be sequenced with an rclone job so you can copy your backup to the storage platform of your choosing. And using mitto scheduling, you can do this on a schedule as often as you wish.

EDIT one note of caution: Depending on how much data is in your files folder and database, these files could be quite large. You should ensure you have sufficient disk space before running this job, and after copying it to another location (S3, FTP, etc) it would be a good idea to remove the backup file.