Using Ofelia with Frappe Docker for Auto Backup

We have deployed Frappe via docker using the single compose set-up. We found out that auto-backup is not running since it requires cron. A quick search led us to this fairly recent discussion in this forum that points to this documentation on how to set up cron job that will execute docker compose.

I recently found out about Ofelia, a job scheduler docker service that can be used in replacement to cron. Has anybody tried using this in production with Frappe?

1 Like

I use GitHub - crazy-max/swarm-cronjob: Create jobs on a time-based schedule on Docker Swarm

If I try Ofelia I’ll write a post or reply here. If you manage to setup then add how-to here on forum.

1 Like

Thank you for this. I am also trying Ofelia as of this moment but I cannot seem to make it work yet. I will post an update here also if any thing comes up.

I was able to execute scheduled backup by adding the following under the services configuration of the single compose file:

frontend:
   # Configurations for frontend service from the single compose file will appear here
    
   labels:
      #Allow Ofelia to exectue job in this container
      ofelia.enabled: "true"
      #Let the frappe user to execute the job called `site-backup` instead of root
      ofelia.job-exec.site-backup.user: "frappe"
      #Schedule the job to be run daily
      ofelia.job-exec.site-backup.schedule: "@daily"
      #This is the job to be executed
      ofelia.job-exec.site-backup.command: "bench --site frontend backup"

ofelia:
    image: mcuadros/ofelia:latest
    depends_on:
      - frontend
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ofelia-logs:/var/log/ofelia
    labels:
      #Allow saving of logs when an error occured
      ofelia.save-folder: "/var/log/ofelia"
      ofelia.save-only-on-error: "true"
      #Remove old logs by running a job in this container that deletes logs every day
      ofelia.job-local.clean-logs.schedule: "@daily"
      ofelia.job-local.clean-logs.command: "find /var/log/ofelia/ -type f -mtime +7 -print -delete"

The configuration I used here uses labels, but it can be set using a configuration file. More details can be found here.

What I am wondering now is why the Download Backups page of Frappe is still blank. What should I expect to see in this page anyway?