mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.87k stars 1.17k forks source link

A docker newbie ask a docker question (backup) #858

Closed jm3west closed 6 years ago

jm3west commented 6 years ago

Hi,

is it possible just compress (tar) the mailcow_dockerized complete folder and good is. When I have a problem then I do it uncompress the tar archive and the job goes on

Is this wrong?

mkuron commented 6 years ago

That‘s not the only place that contains Mailcow data. /var/lib/docker/aufs or /var/lib/docker/overlayfs contains the Docker images, but they can usually be retrieved again with docker-compose pull, so most people don‘t back them up. /var/lib/docker/volumes contains all the user mailboxes, databases, etc., so you need to back that up too.

Siassei commented 6 years ago

@jm3west For backup strategie, replace the tar-archive with an emashing tool like borg https://borgbackup.readthedocs.io

You need to backup the mounted volumes + your mailcow folder. If you will restore the entry same system, you should also backup the used images of mailcow-service.

Example script file to backup an docker-compose service volumes with (optinal) images. https://github.com/Siassei/docker-volume-backup/blob/master/docker_full_backup.sh

Usage: (note, it is dev-status. but a good entry point for your env)

MODE=backup # or restore

path=/opt/mydocker/project1/docker-compose.yml
project=project1
BACKUP_DIR=/tmp/mybackups
DATE=xxxx-xx-xx # with borg, that feature is not needed and currently sticked with x's

#export EXCLUDE_CONTAINER=1
#export EXCLUDE_VOLUMES=1

./docker_full_backup.sh $path $project $BACKUP_DIR $MODE $DATE
pixelyo commented 6 years ago

@Siassei would you be willing to create a backup and restore script for mailcow? It would be amazing to have such a script similar to the update script.

@mkuron what are all the things to backup? We have the mailboxes and databases already referenced in the documentation. What else is missing?

pixelyo commented 6 years ago

seems like these things add to the mailboxes and database:

but there is probably more. found this information in a pull request about a backup script

mkuron commented 6 years ago

812 and #639 were attempts at backup scripts that were never finished. All the necessary information is in my comments there.

pixelyo commented 6 years ago

@mkuron thank you so these are the things mentioned in the pull requests:

I see two more docker volumes on my system:

Are these volumes holding anything important?

I could also imagine that a backup of the mailcow-dockerized directory would be worth to be backed up.

--

general idea: would it be enough to just stop mailcow, make a copy of all volumes in /var/lib/docker/volumes/, make a copy of the mailcow-dockerized directory and then restart mailcow?

andryyy commented 6 years ago

I wrote something for all important data, will push soon.

mkuron commented 6 years ago

The backup script is now available in master.