If by "safe" you mean "consistent", then the exported archive will be filesystem consistent.
The docker export
command, as any other classical backup method, won't solve the problem of being application consistent.
Apache and Memcached won't be an issue, since they don't need storage to maintain any kind of state.
But backuping Mysql this way will probably make your database restart in recovery mode, if you run a container from the image generated by docker export
.
In particular, if backuped when having to perform write activity (insert, updates..),
as with any other filesystem-level backup, you will loose a few transactions.
If you need your Mysql backuped datafiles to be 100% consistent and to reflect the exact state of your data, you have to either:
- Stop Mysql before running
docker export
- Stop the whole container
- Have something connecting to Mysql before running the export command, and run
flush tables with read lock;
. When the export completes, you'd have to run unlock tables;
The backuped data files (generally under /var/lib/mysql) will be consistent.
- Use the classical Mysql backup tools (
mysqldump
...)