Packing zfs snapshots with tar on running container

dominikp

Member
Aug 28, 2018
36
3
13
38
I just want to clear out some things.

I have created some dataset on host.
Code:
rpool/data/101-jenkinsfolder
This dataset is mounted in container
Code:
mp0: /rpool/data/101-jenkinsfolder,mp=/mnt/101-jenkinsfolder

Because proxmox wont backup it, i need to do it manually. I would want to do it like this:
Code:
zfs snapshot rpool/data/101-jenkinsfolder@snapshot_name
cd /rpool/data/101-jenkinsfolder/.zfs/snapshot
tar -cvzf /some_backup_dir/snapshot_name.tar.gz snapshot_name/

QUESTIONS
1. I assume that content of snapshot is frozen so there should be no problem to perform this process on running machine? Because thats why i want to make snapshot before packing.
2. Snapshots are incremental so i dont have to worry about their number? I dont have to delete old ones because then i will destroy the "base" data for newer snapshots?
 
Last edited:
QUESTIONS
1. I assume that content of snapshot is frozen so there should be no problem to perform this process on running machine? Because thats why i
want to make snapshot before packing.
Yes. If nothing weird happens, the filesystems in .zfs/snapshot are read-only.
2. Snapshots are incremental so i dont have to worry about their number? I dont have to delete old ones because then i will destroy the "base" data for newer snapshots?
You can delete older snapshots, while keeping newer ones (and vice versa). ZFS handles resolving the differences internally. If a dataset really depends on another one and you want to destroy that one, ZFS will tell you and refuse to delete it (except if you pass the recursive switch -r).
 
Thanks for reply!

You can delete older snapshots, while keeping newer ones (and vice versa). ZFS handles resolving the differences internally. If a dataset really depends on another one and you want to destroy that one, ZFS will tell you and refuse to delete it (except if you pass the recursive switch -r).

Ok, but it doesnt make much sense right? I mean, deleting old snapshots wont give you additional space?
 
You should always get at least a little bit of space back and if some of the changes are over-written by others you can gain more space. For example:

Code:
root@pve /myzpool/myfs # zfs list -o space -r -t all myzpool/myfs
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
myzpool/myfs                 21.4G  39.2M        0B   39.2M             0B         0B
myzpool/myfs@snap1               -     0B         -       -              -          -

root@pve /myzpool/myfs # dd if=/dev/urandom of=file count=10000 bs=4K    
10000+0 records in
10000+0 records out
40960000 bytes (41 MB, 39 MiB) copied, 0.349116 s, 117 MB/s

root@pve /myzpool/myfs # zfs list -o space -r -t all myzpool/myfs
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
myzpool/myfs                 21.4G  78.4M     39.2M   39.2M             0B         0B
myzpool/myfs@snap1               -  39.2M         -       -              -          -

root@pve /myzpool/myfs # zfs snapshot myzpool/myfs@snap2         

root@pve /myzpool/myfs # zfs list -o space -r -t all myzpool/myfs
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
myzpool/myfs                 21.4G  78.4M     39.2M   39.2M             0B         0B
myzpool/myfs@snap1               -  39.2M         -       -              -          -
myzpool/myfs@snap2               -     0B         -       -              -          -

root@pve /myzpool/myfs # dd if=/dev/urandom of=file count=10000 bs=4K     
10000+0 records in
10000+0 records out
40960000 bytes (41 MB, 39 MiB) copied, 0.24106 s, 170 MB/s

root@pve /myzpool/myfs # zfs list -o space -r -t all myzpool/myfs
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
myzpool/myfs                 21.4G   118M     78.3M   39.2M             0B         0B
myzpool/myfs@snap1               -  39.2M         -       -              -          -
myzpool/myfs@snap2               -  39.2M         -       -              -          -

root@pve /myzpool/myfs # zfs destroy myzpool/myfs@snap1 

root@pve /myzpool/myfs # zfs list -o space -r -t all myzpool/myfs
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
myzpool/myfs                 21.4G  78.4M     39.2M   39.2M             0B         0B
myzpool/myfs@snap2               -  39.2M         -       -              -          -

The USED column for a snapshot shows how much space can be gained by deleting that snapshot. The USEDSNAP column for the dataset shows how much space is used by all snapshots together.
 
  • Like
Reactions: dominikp

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!