Access zfs-snapshots inside lxc container

udo

Distinguished Member
Apr 22, 2009
5,977
199
163
Ahrensburg; Germany
Hi,
I've tested zfs-snapshots with samba and shadow_copy2 to access old file versions which are created with zfs-snapshots.
This work well on the host, but I don't want to use samba on the host directly.
But if I snapshot an container mount point, I can see inside the container the snapshots, but no content:
Code:
ls -lsa /export/data/.zfs/snapshot/zfs-auto-snap_05-2019-02-22-1234
ls: cannot access '/export/data/.zfs/snapshot/zfs-auto-snap_05-2019-02-22-1234/.': Object is remote
ls: cannot access '/export/data/.zfs/snapshot/zfs-auto-snap_05-2019-02-22-1234/..': Object is remote
On the host I see the content:
Code:
ls -lsa /rpool/data/subvol-100-disk-1/.zfs/snapshot/zfs-auto-snap_05-2019-02-22-1234/
total 2
1 drwxr-xr-x 4 xshare   root 4 Feb 22 12:11 .
0 drwxrwxrwx 2 root     root 2 Feb 22 13:36 ..
1 drwxrwxrwx 2 xshare   root 2 Feb 22 12:11 data
1 drwxrwxrwx 4 xshare   root 4 Feb 22 12:11 gamma
Is there an way to access the snapshot-content inside an container?

Udo
 
Is the container unprivileged? (that probably will not work)

for privileged I would need to test it ....
 
Hi Stoiko,
no it's an privileged one
Code:
cat /etc/pve/lxc/100.conf
arch: amd64
cores: 2
hostname: recovery
memory: 1024
mp0: local-zfs:subvol-100-disk-1,mp=/export/data,replicate=0,size=8G
net0: name=eth0,bridge=vmbr0,gw=10.X.X.1,hwaddr=9E:95:7C:C7:2D:FA,ip=10.X.X.9/24,type=veth
ostype: debian
rootfs: local-zfs:subvol-100-disk-0,size=8G
swap: 512
Udo
 
Hmm, I need to check but I thought, I'm running ZFS snapshots with the samba stuff on an LX(C) container and it is working fine.
 
Oh right ... I don't see files, but I also do not get an error, I just see empty snapshot folder:

Code:
root@fileserver:/data/documents/.zfs/snapshot# du -csm *
0       2017-06-24_22-32-06
0       2017-06-24_23-00-51
0       2017-06-24_23-01-05
0       2017-06-24_23-01-22
0       20170924
0       20171203
0       20180330
0       20180812
0       20180818
0       20181007
0       migrate
0       migrate-lat-snapshot
0       insgesamt

I was kidding myself ... I would have gotten a big shock if I tried to restore files :-D
 
Oh right ... I don't see files, but I also do not get an error, I just see empty snapshot folder:

Code:
root@fileserver:/data/documents/.zfs/snapshot# du -csm *
0       2017-06-24_22-32-06
0       2017-06-24_23-00-51
0       2017-06-24_23-01-05
0       2017-06-24_23-01-22
0       20170924
0       20171203
0       20180330
0       20180812
0       20180818
0       20181007
0       migrate
0       migrate-lat-snapshot
0       insgesamt

I was kidding myself ... I would have gotten a big shock if I tried to restore files :-D
Hi,
same like my try... not the right thing for getting data back (but work on the host).

Udo
 
hm - as said - haven't tried it myself - but the following issues in ZFS and LXC could be helpful:
https://github.com/zfsonlinux/zfs/issues/4722
https://discuss.linuxcontainers.org...er-access-to-hundreds-of-zfs-snapshots/3277/6

Hope it helps
Hi Stoiko,
thanks for the links, but the fist one discribe an io-issue, which isn't the point for me (only few snapshots with only few data).

The second show the problem, but no solution - seems, that the zfs-magic with mounting of snapshots can't work inside an container...

In this case, I must use samba on the pve-host itself - not the best solution.

Udo
 
Hi,

But you will use more space. And the OP said he allready use snapshots on the host.

Good luck / Bafta !
Well if you are talking about 350MB container which is extra for samba, everything else is on host including snapshots :)
And i dont use sshfs :) I dont understand what more space do you mean?
And trust me,something like samba is better on CT for backup/restore purpose :>
 
Hi,

But you will use more space. And the OP said he allready use snapshots on the host.

Good luck / Bafta !
As the name speak for it self

PVE 6.3-6 + zfs host storage pool + LXC + turnkey file server + SMB + shadow_copy2​

 
I don't know man, i am a linux guy not so long but how it is possible that Bind mounted zfs folder can ocupy space inside CT this i dont understand. And i don't see it.

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/pve-vm--107--disk--0 8191416 1307256 6448348 17% /
hoax_bck/hoax_bck_data 2087138048 1225145088 861992960 59% /srv/storage
none 492 4 488 1% /dev
udev 16349808 0 16349808 0% /dev/fuse
tmpfs 16407572 0 16407572 0% /dev/shm
tmpfs 16407572 10400 16397172 1% /run
tmpfs 5120 0 5120 0% /run/lock
tmpfs 16407572 0 16407572 0% /sys/fs/cgroup

Here i see from within CT the hoax_bck/hoax_bck_data mounted host zfs folder.
Now where i can find that it is occupiing CT storage?!
Screenshot_130.png
 
I don't know man, i am a linux guy not so long but how it is possible that Bind mounted zfs folder can ocupy space inside CT this i dont understand
Hi,

I am not say this. I say that you have a share (physical on binmount /srv/storage. Now a samba user will delete let say 100 G. If you have shadow copy active, then this 100 G wil be not be deleted, but only moved in the same bindmount according with your smb.conf.

And after some time the deleted files from shadow copy will grow ....

Good luck / Bafta!
 
This work well on the host, but I don't want to use samba on the host directly.
But if I snapshot an container mount point, I can see inside the container the snapshots, but no content:

Hi,

Maybe you could try (I do not know if it work or not) to add a new bindmount disk to your CT using the snapshot path: /export/data/.zfs/snapshot/zfs-auto-snap_05-2019-02-22-.....

Good luck / Bafta !
 
Hi,

I am not say this. I say that you have a share (physical on binmount /srv/storage. Now a samba user will delete let say 100 G. If you have shadow copy active, then this 100 G wil be not be deleted, but only moved in the same bindmount according with your smb.conf.

And after some time the deleted files from shadow copy will grow ....

Good luck / Bafta!
I dont have any recycle activated for smb deleted files.would you mind to take some time and give example? So i have my smb that i access from another PC,i delete the file and now what? What should i check? If the space was cleard? But i dont think it will work like this as there were previous snapshots? I would need to destroy all the snapshots and suppoust the deleted file must lower the used space? Do i understand you correctly?
 

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!