mirror of
https://github.com/frappe/frappe_docker.git
synced 2025-01-06 23:43:59 +00:00
docs: backup and push (#19)
This commit is contained in:
parent
096c5afb02
commit
3e424fb522
@ -1,105 +1,41 @@
|
||||
Install [crazy-max/swarm-cronjob](https://github.com/crazy-max/swarm-cronjob) and then deploy following stack.
|
||||
Create backup service or stack.
|
||||
|
||||
```yaml
|
||||
# backup-job.yml
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
backup:
|
||||
image: frappe/erpnext-worker:version-13
|
||||
entrypoint: ["bash", "-c"]
|
||||
command: ["docker-entrypoint.sh backup; docker-entrypoint.sh push-backup"]
|
||||
environment:
|
||||
- WITH_FILES=1
|
||||
- BUCKET_NAME=backups
|
||||
- REGION=region
|
||||
- ACCESS_KEY_ID=access_id_from_provider
|
||||
- SECRET_ACCESS_KEY=secret_access_from_provider
|
||||
- ENDPOINT_URL=https://region.storage-provider.com
|
||||
- BUCKET_DIR=frappe-bench
|
||||
volumes:
|
||||
- "sites-vol:/home/frappe/frappe-bench/sites"
|
||||
deploy:
|
||||
labels:
|
||||
- "swarm.cronjob.enable=true"
|
||||
- "swarm.cronjob.schedule=0 */3 * * *"
|
||||
- "swarm.cronjob.skip-running=true"
|
||||
replicas: 0
|
||||
restart_policy:
|
||||
condition: none
|
||||
networks:
|
||||
- frappe-network
|
||||
|
||||
volumes:
|
||||
sites-vol:
|
||||
external: true
|
||||
name: frappe-bench-v12_sites-vol
|
||||
|
||||
networks:
|
||||
frappe-network:
|
||||
external: true
|
||||
```
|
||||
|
||||
Note:
|
||||
|
||||
- In Above stack, `backup` runs every 3 hours.
|
||||
- Change image and tag version as per need.
|
||||
- Change environment variables as per the bucket credentials.
|
||||
- Change cron string(s) as per need.
|
||||
|
||||
### For docker-compose based installation not using docker swarm
|
||||
|
||||
Add minio
|
||||
|
||||
```yaml
|
||||
version: "3.7"
|
||||
services:
|
||||
minio:
|
||||
image: minio/minio
|
||||
command: ["server", "/data"]
|
||||
environment:
|
||||
- MINIO_ACCESS_KEY=RANDOMACCESSKEY
|
||||
- MINIO_SECRET_KEY=RANDOMSECRETKEY
|
||||
volumes:
|
||||
- "minio-vol:/data"
|
||||
networks:
|
||||
- erpnext-network
|
||||
# Do not enable, check how to secure minio, out of scope of this project.
|
||||
#labels:
|
||||
# - "traefik.enable=true"
|
||||
# - "traefik.http.routers.minio.rule=Host(`backup.example.com`)"
|
||||
# - "traefik.http.routers.minio.entrypoints=websecure"
|
||||
# - "traefik.http.routers.minio.tls.certresolver=myresolver"
|
||||
# - "traefik.http.services.minio.loadbalancer.server.port=9000"
|
||||
|
||||
networks:
|
||||
erpnext-network:
|
||||
external: true
|
||||
name: <your_frappe_docker_project_name>_default
|
||||
|
||||
volumes:
|
||||
minio-vol:
|
||||
```
|
||||
|
||||
Create backup service. Create file `backup-job.yml`
|
||||
|
||||
```yaml
|
||||
version: "3.7"
|
||||
services:
|
||||
push-backup:
|
||||
image: frappe/erpnext-worker:v13
|
||||
entrypoint: ["bash", "-c"]
|
||||
command: ["docker-entrypoint.sh backup; docker-entrypoint.sh push-backup"]
|
||||
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:
|
||||
- WITH_FILES=1
|
||||
- BUCKET_NAME=erpnext
|
||||
- REGION=us-east-1
|
||||
- ACCESS_KEY_ID=RANDOMACCESSKEY
|
||||
- SECRET_ACCESS_KEY=RANDOMSECRETKEY
|
||||
- ENDPOINT_URL=http://minio:9000
|
||||
- BUCKET_DIR=backups
|
||||
- BACKUP_LIMIT=8
|
||||
- ENDPOINT_URL=https://endpoint.url
|
||||
volumes:
|
||||
- "sites-vol:/home/frappe/frappe-bench/sites"
|
||||
# Uncomment in case of Docker Swarm with crazy-max/swarm-cronjob
|
||||
# deploy:
|
||||
# labels:
|
||||
# - "swarm.cronjob.enable=true"
|
||||
# - "swarm.cronjob.schedule=0 */3 * * *"
|
||||
# - "swarm.cronjob.skip-running=true"
|
||||
# replicas: 0
|
||||
# restart_policy:
|
||||
# condition: none
|
||||
networks:
|
||||
- erpnext-network
|
||||
|
||||
@ -114,8 +50,14 @@ volumes:
|
||||
name: <your_frappe_docker_project_name>_sites-vol
|
||||
```
|
||||
|
||||
Add crontab entry for backup every 6 hours
|
||||
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:
|
||||
|
||||
- Install [crazy-max/swarm-cronjob](https://github.com/crazy-max/swarm-cronjob) for docker swarm.
|
||||
- Uncomment `deploy` section in case of usage on docker swarm.
|
||||
- Change the cron string as per need.
|
||||
|
Loading…
Reference in New Issue
Block a user