Skip to content

LocalSnapshotsOnly

Luca Finzi Contini edited this page Oct 27, 2024 · 4 revisions

Making Snapshots on the NAS only

Sometimes a user might want to have only a NAS server with snapshots, and no backup server (not adviseable, but it is a possible choice anyway).

This scenario was suggested to me by my friend Francesco. Thank you, Frank! :)

In detail, his use case is just having a nas that can perform local snapshots, which could be browsed via Samba as we already have set up.

So let's modify some files and perform a local snapshot without performing a backup. In order to perform just a snapshot, we need to use the switch -s and the complete backup descriptor. Clearly, in this case, since no remote backup server will be contacted, the part of the descriptor that describes the remote server can be fake. Here is an example:

SRC_POOL=zfspool
SRC_DATASET=Documents

DST_POOL=fakepool
DST_DATASET=FakeDir

DST_USERNAME=fuser
DST_ADDR=fake

Let's create a file like this and name it ExampleDocumentsLocalSnapshots.bkp.

If you launch a snapshot operation with no changes in the Documents folder, the script recognizes that and does not create any useless snapshot:

user@nas:~/src/zfs-backup$ ./zfs-backup.sh -s ExampleDocumentsLocalSnapshots

####################################################################################################
                 ZFS Backup Script - server name = nas
####################################################################################################

Starting Zfs backup - Snapshot operaton requested.
Snapshot requested on zfspool/Documents
Latest Snapshot is zfspool/Documents@2024.10.27-21.59.11
Finding differences between zfspool/Documents@2024.10.27-21.59.11 and current status of zfspool/Documents - this could take some time...
There are no local differences -> the latest local snapshot will be considered as current snapshot.
Snapshot operaton complete
user@nas:~/src/zfs-backup$ zfs list -t snapshot
NAME                                    USED  AVAIL  REFER  MOUNTPOINT
zfspool/Documents@2024.07.26-00.48.47   346K      -   474M  -
zfspool/Documents@2024.10.27-21.59.11     0B      -   474M  -
user@nas:~/src/zfs-backup$

As you can see, the last snapshot was zfspool/Documents@2024.10.27-21.59.11, which is the same listed by the command zfs list -t snapshot. Now we will perform 3 more snapshots:

Adding a big file:

user@nas:~/src/zfs-backup$ ./zfs-backup.sh -s ExampleDocumentsLocalSnapshots

####################################################################################################
                 ZFS Backup Script - server name = nas
####################################################################################################

Starting Zfs backup - Snapshot operaton requested.
Snapshot requested on zfspool/Documents
Latest Snapshot is zfspool/Documents@2024.10.27-21.59.11
Finding differences between zfspool/Documents@2024.10.27-21.59.11 and current status of zfspool/Documents - this could take some time...
There are differences -> creating a snapshot...
Creating snapshot...
Snapshot performed correctly: zfspool/Documents@2024.10.27-22.13.33
Snapshot operation complete.

Here is the corresponding content: Adding a big file

Deleting 3 files:

user@nas:~/src/zfs-backup$ ./zfs-backup.sh -s ExampleDocumentsLocalSnapshots

####################################################################################################
                 ZFS Backup Script - server name = nas
####################################################################################################

Starting Zfs backup - Snapshot operaton requested.
Snapshot requested on zfspool/Documents
Latest Snapshot is zfspool/Documents@2024.10.27-22.13.33
Finding differences between zfspool/Documents@2024.10.27-22.13.33 and current status of zfspool/Documents - this could take some time...
There are differences -> creating a snapshot...
Creating snapshot...
Snapshot performed correctly: zfspool/Documents@2024.10.27-22.15.19
Snapshot operation complete.

Here is the corresponding content: Deleting 3 files

Changing 2 files.

user@nas:~/src/zfs-backup$ ./zfs-backup.sh -s ExampleDocumentsLocalSnapshots

####################################################################################################
                 ZFS Backup Script - server name = nas
####################################################################################################

Starting Zfs backup - Snapshot operaton requested.
Snapshot requested on zfspool/Documents
Latest Snapshot is zfspool/Documents@2024.10.27-22.15.19
Finding differences between zfspool/Documents@2024.10.27-22.15.19 and current status of zfspool/Documents - this could take some time...
There are differences -> creating a snapshot...
Creating snapshot...
Snapshot performed correctly: zfspool/Documents@2024.10.27-22.18.59
Snapshot operation complete.

Here is the corresponding content: Changing 2 files

Final situation

Here is the final situation of our nas, with several snapshots.

Final Situation

Let's say that, after some local snapshot, we made up our mind and now we want to backup all the situation we have on nas over to the backup server. Let's check out Backup after several snapshots !

Clone this wiki locally