Local backups of dockerized install

try like this, edit the scripts as per your need, you can even use custom script instead of existing method

version: "3.7"
services:
  push-backup:
    image: frappe/erpnext-worker:v13.11.1
    entrypoint: ["bash", "-c"]
    command: > 
      docker-entrypoint.sh backup;
      mv ./mysite.localhost/private/backups/* /home/frappe/backups;
    # command: ["/opt/custom.sh"]
    environment:
      - WITH_FILES=1
    volumes:
      - "sites-vol:/home/frappe/frappe-bench/sites"
      - ./backups:/home/frappe/backups
      # - /custom/executable/script/to/run.sh/:/opt/custom.sh
    networks:
      - erpnext-network

networks:
  erpnext-network:
    external: true
    name: <your_frappe_docker_project_name>_default

volumes:
  sites-vol:
    external: true
    name: <your_frappe_docker_project_name>_sites-vol
francois@francois-pc:~$ /usr/local/bin/docker-compose -f /media/francois/Storage/Documents/backup-job.yml start > /dev/null
Starting push-backup ... failed
ERROR: No containers to start
ERROR: 1

for docker-compose start to work the projectā€™s containers must be first created.

docker-compose up -d will create the containers. Once containers are create they can be started.

francois@francois-pc:/media/francois/Storage/Documents$ docker-compose up -d
Creating documents_push-backup_1 ... done

check the backups directory now.

You need to understand volumes in docker-compose, check docs.

the yml mounts ./backups:/home/frappe/backups

the script takes backup and moves the files to this mounted directory.

The backups should be available in ./backups directory

Think I should find another way to backup ERPNext data.
I donā€™t know bash nor Docker.

Hey @revant_one ,

I have a similar setup using the steps described here: Installing the Docker image on a local machine without Letsencrypt so we can access it with http://localhost

Iā€™d like to have backups of my erpnext instance.
The volumes used by the docker-compose are these 4 I believe:

  • frappe_docker_assets ā†’ seem to be the css/js etc. for the site, no need to back it up ?
  • frappe_docker_db-data ā†’ the mysql data, to be backed up every time I guess ?
  • frappe_docker_redis-data ā†’ afaik redis is only cache stuff right ? I guess I can ignore ?
  • frappe_docker_sites ā†’ the sites data, can I only back this up once ? as the data shouldnā€™t change right ?

When restoring, can I just follow the regular docker-compose up etc., and then once my containers are running simply replace the two volumes I backed up (in case I only back up frappe_docker_db-data and frappe_docker_sites) ?

Last but not least @francois072 if you use Docker Desktop, and if @revant_one confirms what I said earlier, you can just download the ā€œVolumes Backup & Shareā€ extension which allows to backup and replace docker volumes very easily. If this works, then the backing up becomes a breeze !

Thanks again for the support, and happy holidays.
Zauber.

sites and db-data are the volumes to be backed up.

if you depend on volume backups, you can explore alternatives for snapshots.

or you can use this built in bench backup command. frappe_docker/backup-and-push-cronjob.md at main Ā· frappe/frappe_docker Ā· GitHub