short version
I'd like to synchronize a remote directory, whose name changes. Something like (not working!):
rsync -a '[email protected]:~/.zfs/snashots/$(ls -d Automatic-* | tail -1)/foo' ~/foo
longer version / background
I have an internet accessible hard drive (Hetzner Storage Box), which regularly creates ZFS snapshots. I can access the snapshots within the /.zfs/snapshots
directory. For every snapshot there is a subdirectory named after a pattern like Automatic-<timestamp>
:
$ ls /.zfs/snapshots
Automatic-2021-10-01T00-25-22 Automatic-2021-12-01T00-23-14 Automatic-2022-02-01T00-21-38
Each of this folders contain a frozen state of my files at the time of snapshot creation. I would like to regularly mirror the contents of the latest folder to my home server, because this folder contains the latest 'frozen' state of my files. Because the timestamp pattern is sortable, the latest folder could for example be queried by following command:
$ ls -d Automatic-* | tail -1
Automatic-2022-04-01T00-24-16
Is there any possibility to tell rsync how to get the 'latest' remote source directory?
I haven't tried the command substitution from my example above - but I think that wouldn't work with rsync. However I have tried to create a symbolic link (ln -s '/path/to/$(ls -d Automatic-* | tail -1)/foo' /target
). However the ln
command resolves the path on creation and not on access.
Any idea?