I've been using BTRFS for development and am loving the simplicity and features it provides.
One thing I do a lot is database snapshot on docker volume (to test db migration) - which I can easily do with BTRFS.
Here's how:
- Convert docker volume directory into BTRFS subvolume
- Snapshot the docker volume (now a BTRFS subvolume)
Convert docker volume directory into BTRFS subvolume
# Directory to convert into BTRFS subvolume
dirPath='/var/lib/docker/test_docker_volume'
# Rename original dierctory
mv "${dirPath}" "${dirPath}_original"
# Create btrfs subvolume
btrfs subvolume create "${dirPath}"
# Copy as "reflink" for speed and save space
cp --archive --one-file-system --reflink=always \
"${dirPath}_original/." "${dirPath}"
# Remove old directory
rm -rf --one-file-system "${dirPath}_original"
Snapshot the docker volume
Create a read-only snapshot of test_docker_volume
docker volume:
btrfs subvolume snapshot -r \
/var/lib/docker/test_docker_volume \
/var/lib/docker/test_docker_volume_bak
Top comments (1)
Thank you!