2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-08 14:21:05 +00:00
frappe_docker/docs/backup-and-push-cronjob.md
Revant Nandgaonkar e6088af885
refactor: build only one frappe/erpnext image (#1032)
* ci: skip frappe builds

* refactor: build only one frappe/erpnext image

* fix: lint nginx entrypoint script

* docs: update and organize docs

* docs: fix lint errors

* fix(custom): pass base64 encoded apps json

* ci: update dependabot

* docs: update contributing

* docs: remove info about multi image setup

* fix: initiate empty common_site_config.json

default config has host keys set to localhost
causes connection errors

* docs: add details for pwd volumes

* fix: symlink assets instead of copy

* fix: nginx private files

* ci: skip docker compose v2 install for ubuntu-latest

* fix: organize layers

* feat: allow remove git remote for custom image

* docs: allow remove git remote for custom image

* fix: remove duplicate --apps_path
2023-01-16 04:20:09 +05:30

1.3 KiB

Create backup service or stack.

# backup-job.yml
version: "3.7"
services:
  backup:
    image: frappe/erpnext:v14
    entrypoint: ["bash", "-c"]
    command: |
      for SITE in $(/home/frappe/frappe-bench/env/bin/python -c "import frappe;print(' '.join(frappe.utils.get_sites()))")
      do
        bench --site $SITE backup --with-files
        push-backup \
          --site $SITE \
          --bucket $BUCKET_NAME \
          --region-name $REGION \
          --endpoint-url $ENDPOINT_URL \
          --aws-access-key-id $ACCESS_KEY_ID \
          --aws-secret-access-key $SECRET_ACCESS_KEY
      done      
    environment:
      - BUCKET_NAME=erpnext
      - REGION=us-east-1
      - ACCESS_KEY_ID=RANDOMACCESSKEY
      - SECRET_ACCESS_KEY=RANDOMSECRETKEY
      - ENDPOINT_URL=https://endpoint.url
    volumes:
      - "sites-vol:/home/frappe/frappe-bench/sites"
    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

In case of single docker host setup, add crontab entry for backup every 6 hours.

0 */6 * * * /usr/local/bin/docker-compose -f /path/to/backup-job.yml up -d > /dev/null

Notes:

  • Change the cron string as per need.