My setup to quickly restore in case of problems is quite simple:
In my home folder on linux I have a subfolder named services
and inside this services
folder I have one subfolder for each of my services;
/home/x/services
/home/x/services/nodered
/home/x/services/zigbee2mqtt
etc.
Each service subfolder contains the files docker-compose.yml
and .env
as well as a subfolder data
. Latter I use for service specific volume definitions in docker-compose.yml, f.e.
volumes:
- .data/config:/whatever/config
Each other night I stop each service, tar its directory and start it again. With the exception of influxdb this is only a matter of seconds per service. And at 3 a.m. I don't care ... backup is done via crontab script, run by root:
#!/bin/bash
cd /home/x/services
# Run through all subfolder in /home/x/services
for dir in */ ; do
# echo "Change to $dir"
cd "$dir"
docker compose down
cd ..
tar -cvzf "/mnt/backup/${dir%/}-$(date '+%F').tar.gz" "$dir"
cd "$dir"
docker compose up -d
cd ..
done
With this I have full and separate backups of all my services. Each in a single file with date tag and with all my settings and all my data.
In case I have to recover, I just download required backups, untar
them and docker compose up -d
each service. Assuming docker is running on the new host, docker will automatically pull the required service image on each services first start.
As for nodered and your example:
No need to deal with dockerfile, package.json, etc. It is only a matter of standard file handling. Any nodered-date.tar.gz not only contains package.json but all installed packages as well.
This does not explain how to achieve a one-button-restore feature. But it could very well lay the foundation. The rest depends on your particular setup.