29
loading...
This website collects cookies to deliver better user experience
docker-compose.yml
docker-compose exec mariadb sh -c 'exec mysqldump --all-databases --add-drop-database -u"$MYSQL_USER" -p"$MYSQL_ROOT_PASSWORD"' > ./dump.sql
mysqldump
on the server with two specific options --all-databases
and --add-drop-database
these are important since they ensure that when the backup is restored old data doesn't get overlapped with new data.mysqldump
is piped into a dump.sql
file. This is your backup ✅️docker-compose exec -T mariadb sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < dump.sql
mysql
command we restore the dump through a pipeBefore running these commands is it highly recommended to shutdown your Appwrite instance to ensure you get a complete backup.
mkdir -p backup && docker run --rm --volumes-from "$(docker-compose ps -q appwrite)" -v $PWD/backup:/backup ubuntu bash -c "cd /storage/functions && tar cvf /backup/functions.tar ."
mkdir -p backup && docker run --rm --volumes-from "$(docker-compose ps -q appwrite)" -v $PWD/backup:/backup ubuntu bash -c "cd /storage/uploads && tar cvf /backup/uploads.tar ."
--rm
will delete the container once it's done running. The reason we want this is because this container is only being used to package up our backup and give it to the host machine. --volume-from
This flag special as it will mount all of the volumes of the container we give it. To get the container ID we want we use a $(docker-compose ps -q appwrite)
to get the ID within the command-v
This flag is being used to mount a volume onto our new container which will give us access to a backup folder we created using the mkdir
command at the startubuntu
is the image we are basing our new container onbackup
folder which containsuploads.tar
and functions.tar
these are your backups. Keep them safe.docker-compose.yml
file and simply run the following commands to restore the backup. Please note that the Appwrite instance should be shutdown while running these commands.
docker run --rm --volumes-from "$(docker-compose ps -q appwrite)" -v $PWD/backup:/restore ubuntu bash -c "cd /storage/functions && tar xvf /restore/functions.tar --strip 1"
docker run --rm --volumes-from "$(docker-compose ps -q appwrite)" -v $PWD/backup:/restore ubuntu bash -c "cd /storage/uploads && tar xvf /restore/uploads.tar --strip 1"
29