Skip to main content

Backup Docker Volumes (Nextcloud Example)

Description:

In this guide, you will learn how to securely backup Docker volumes using Nextcloud as an example. Docker volumes play a critical role in persisting data within containerized applications, and backing them up is essential for data safety and recovery. Follow these step-by-step instructions to confidently create backups of Nextcloud's Docker volumes, including the data and configuration directories. Safeguard your valuable data today!

Backup Steps:

Backup Nextcloud Database:

docker run --rm --volumes-from nextcloud-db-1 -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar -C /var/lib/mysql .

Backup Nextcloud Front End:

docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu tar cvf /backup/backupdata.tar -C /var/www/html/data .

docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu tar cvf /backup/backupconfig.tar -C /var/www/html/config .

Restore Steps:

Restore Nextcloud Database:

 

docker run --rm --volumes-from nextcloud-db-1 -v $(pwd):/backup ubuntu bash -c "cd /var/lib/mysql && tar xvf /backup/backup.tar"

Restore Nextcloud Frontend:

docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu bash -c "cd /var/www/html/data && tar xvf /backup/backupdata.tar"

docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu bash -c "cd /var/www/html/config && tar xvf /backup/backupconfig.tar"

Ensure that the paths and container names match your specific setup. Following these instructions, you'll be able to backup and restore Docker volumes, ensuring the safety and integrity of your Nextcloud data.