The docker-snap-volume tool allows you to create and restore snapshot volumes in Docker. When a snapshot is created, a .tar file is generated, which can be restored to the volume as needed.
While developing a script to patch a large database, the need arose to quickly restore the database to its current state. The traditional method of importing a dump took over 7 hours. Thus, a Docker snapshot tool was developed to simplify and expedite this process.
To download the script and set it up on your system, follow the steps below:
Download the script:
sudo curl -SL https://raw.githubusercontent.com/BillRizer/docker-snap-volume/main/docker-snap-volume -o /usr/local/bin/docker-snap-volume
Change permissions:
sudo chmod +x /usr/local/bin/docker-snap-volume
To create a snapshot of a volume, use the command below:
docker-snap-volume -n volume-name -f /absolute/path/to/volume-snapshot.tar --create
-n
: The name of the Docker volume to be snapshotted.
-f
: The absolute path to the .tar file where the snapshot will be saved.
To restore a volume from a snapshot, use the following command:
docker-snap-volume -n volume-name -f /absolute/path/to/volume-snapshot.tar --restore
-n
: The name of the Docker volume to be restored.
-f
: The absolute path to the .tar file of the snapshot to be restored.
Feel free to contribute to this project or open issues for improvements and fixes.