Docker Volume Backup Tutorial: Nextcloud Example

Ғылым және технология

Learn how to securely backup Docker volumes using Nextcloud as an example in this step-by-step tutorial. Docker volumes are crucial for persisting data in containerized applications, and backing them up ensures the safety and recoverability of your valuable data. In this video, we walk you through the process of creating a backup of Nextcloud's Docker volumes, including the data and configuration directories. You'll gain a clear understanding of the commands and steps involved, allowing you to confidently implement volume backups in your Docker environment. Don't risk losing your data-watch this tutorial and safeguard your Docker volumes today!
🔒 BACKUP 🔒
Bookstack - bookstack.elzim.xyz/books/sel...
1️⃣ Backup Nextcloud Database:
Run the following command in your terminal:
docker run --rm --volumes-from nextcloud-db-1 -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar -C /var/lib/mysql .
2️⃣ Backup Nextcloud Data:
Run this command next:
docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu tar cvf /backup/backupdata.tar -C /var/www/html/data .
3️⃣ Backup Nextcloud Configuration:
Lastly, run the command below:
docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu tar cvf /backup/backupconfig.tar -C /var/www/html/config .
🔁 RESTORE 🔁
1️⃣ Restore Nextcloud Database:
Execute the following command:
docker run --rm --volumes-from nextcloud-db-1 -v $(pwd):/backup ubuntu bash -c "cd /var/lib/mysql && tar xvf /backup/backup.tar"
2️⃣ Restore Nextcloud Data:
Use this command for data restoration:
docker run --rm --volumes-from nextcloud-app-1 -v $(pwd):/backup ubuntu bash -c "cd /var/www/html/data && tar xvf /backup/backupdata.tar"
3️⃣ Restore Nextcloud Configuration:
Finally, execute this command:
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 the paths and container names match your setup. By following these instructions, you can confidently backup and restore Docker volumes, protecting your valuable Nextcloud data. Don't risk data loss-watch now and keep your Docker volumes safe! 💾✨
Timestamps:
0:00 Introduction
1:00 Setup Overview
2:11 Setup of Nextcloud
3:50 Stopping Nextcloud and Backing up
7:25 Restoring Backups
11:44 Closing Thoughts

Пікірлер: 19

  • @Techdox
    @Techdox Жыл бұрын

    I hope you enjoyed this video! Make sure to Subscribe if you did! - 96% of my viewers are not subscribed 🫣

  • @cossac
    @cossac3 ай бұрын

    Thanks for this have been trying to get nextcloud aio to backup for 4 hours without success. But this method is so much better and now I have learned to backup my dockers :)

  • @SnordCranston23
    @SnordCranston23 Жыл бұрын

    Thanks for a great video. I will be implementing this process today.

  • @Techdox

    @Techdox

    Жыл бұрын

    Glad it was useful

  • @pavelperina7629
    @pavelperina7629 Жыл бұрын

    Was on my watch later list for two weeks, in the mean time I found own solution. I tried to add podman solution to comment, but youtube doesn't like it and does not like links. Interesting platform, indeed. Most "fun" part about podman is remapping user ids. But I just put NC into maintenance mode run mysqldump and volume export trough zstd pipeline. podman volume export/import are likely commands specific to podman which consume/produce tar on input/output and work with pipes. Maybe stopping containers and doing volume exports is easier, cause restoration process is more simple and it can combined into weekly maintenace task (backup, pull, prune)

  • @Techdox

    @Techdox

    Жыл бұрын

    Great that you found your own way via Podman. I really want to automate the way I showed in the video by creating a pipeline to do it. Will see how that goes!

  • @Techdox

    @Techdox

    Жыл бұрын

    Made a Python script to do just the backups so far, plan to keen working on this - github.com/Techdox/docker_backup

  • @pavelperina7629

    @pavelperina7629

    Жыл бұрын

    @@Techdox Thanks, I was thinking about using syncthing to synchronize backup folder between two servers or ask my friend who mentioned using rsync. At least some use for zimaboard 216, which i replaced by Fujitsu Esprimo Q956.

  • @mevasilev
    @mevasilev2 ай бұрын

    That is extremely useful! Can you suggest how to modify the lines so i can do the back up on another ssd dor example. Can use these commands with cron jobs?

  • @Techdox

    @Techdox

    2 ай бұрын

    Happy to help, feel free to join the discord and we can help you there :) for the latest link go to one my of newer videos and my discord link is in the description :)

  • @RoshanKumar-hs5jt
    @RoshanKumar-hs5jt9 ай бұрын

    Thanks a lot for the video. It has a very clear explanation. One key challenge is observe is the image that you created the first time is not destroyed. So all persistent data still exists. Can you try deleting the image on your local machine or rebuilding it using docker compose up -d --no-deps --build.? I have the data and mariadb folders along with the doccker compose yaml file. however when i try to rebuild the image, the whole links are lost and i am unable to relink my mariadb and data folders. This is especially an issue if we want to move the server to a new computer or restore the installation from back up. Thanks a lot.

  • @Techdox

    @Techdox

    9 ай бұрын

    I might not be 100% understanding your comment but I did remove all content that was being used and restored it. The image itself the docker image shouldn’t really matter much as all I’m doing is pulling the same one if it was deleted

  • @m-pax1743
    @m-pax17435 ай бұрын

    How can i combine it with borg or restic to use incremental backups?

  • @Techdox

    @Techdox

    5 ай бұрын

    Hey, feel free to join the discord. I can help you better there :)

  • @user-qm8pu4jm1g
    @user-qm8pu4jm1g Жыл бұрын

    So there is no gui to do the whole backup and restore docker volume etc in Nextcloud AIO? Can it do history version like Duplicati?

  • @Techdox

    @Techdox

    Жыл бұрын

    Nextcloud AIO may have some solutions for backup but keep in mind this is how to backup and restore Docker volumes in general. It would be great to have a guy front end to do these steps though. Might look into making something

  • @SuperMaxiiiiii
    @SuperMaxiiiiii5 ай бұрын

    I'm thinking of using bind mounts for my nextcloud containers to simplify this backup process, is this a right way to approach this or are there drawbacks.

  • @Techdox

    @Techdox

    5 ай бұрын

    Hey, you can use bindmounts but another suggestion would to use standard volumes and then use something like duplicati to backup. It’s one of my recent videos

  • @SuperMaxiiiiii

    @SuperMaxiiiiii

    5 ай бұрын

    I've decided to use kopia in stead of duplicati after some research@@Techdox now i have succesfully snapshots of all my important data, including the docker volumes.

Келесі