QNAP Snapshots

I wrote a small tool to access QNAP snapshots from the Linux command line.

Pre-requistes:

  • Snapshots have to be enabled
  • You need a /share/netcfg containing the file:
    • In my case, I set this share as read-only with root-squash.
    • `admin.yaml' : contains the private/public keys and the configuration of the forced command. For access control, it is only readable to group and the file is owned by the UNIX group that can do snapshot operations.
    • registry.yaml : this is optional if you are changing the admin username.

Afterwards run:

  • install_key.sh server-name

This installs the public key into the authorized keys. You will need ssh access for this to work.

You need to do this on all the QNAP servers that offer snapshots.

Copy qsnap to somewhere in your path.

Usage

Listing snapshots

qsnap

List snapshots for the current directory

bash qsnap ls file-path

List snapshots for the given file-path. file-path can be provided multiple times.

Reading snapshot files

qsnap cat [--snap=snapid] file1 [file2 file3 ...]

Would display the given file(s) from the snapshot. If snapid is not specified will use the latest available snapshot.

Dumping snapshots

``bash qsnap tar [--snap=snapid] [options] path



Will dump the given `path` as a tarball.  If `snapid` is not
specified will use the latest available snapshot.

The `path` can be either a file or directory.

Additional options:

- `--base64` : Data will be dumped using MIME Base64 encoding
- '--no-compress' : Default is to compress.  This disables compression
- '-v' : Pass `v` flag to `tar` command.

All this can be found on [github](https://github.com/alejandroliu/0ink.net/blob/main/snippets/2023/qsnap).