File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_use_snapshots.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sat Apr 6 01:06:15 2019 UTC (2 years, 9 months ago) by sevan
Branches: MAIN
CVS tags: HEAD
Link to fss(4) manual

    1: # How to use snapshots with NetBSD
    3: Snapshots using [[!template id=man name="fss" section="4"]] aren't a new thing in NetBSD, they have been supported 
    4: since NetBSD 2.0. But their concept and usage is rather unintuitive from what 
    5: you might know from other snapshotting mechanisms such as zfs', so here is a 
    6: tutorial on how to use them.
    8: ## What is a snapshot?
   10: A snapshot is a consistent view on a filesystem at a certain point in time.
   11: This means, you take a snapshot of a filesystem, then create a new file or 
   12: change an existing one, and if you look at the snapshot, it will show you the 
   13: old version of the file or the directory without this file.
   15: ## What is a snapshot not?
   17: A snapshot is no filesystem versioning! Snapshots by fss are read-only 
   18: *views*, and you cannot revert the filesystem back to a snapshot without 
   19: copying all the files on filesystem layer. You can only mount the 
   20: snapshot to see what the filesystem looked like back then, but not more.
   22: ## How to create snapshots?
   24: Snapshots are configured using the tool fssconfig(8). To create a 
   25: snapshot, you have to enter the snapshot device you want to use 
   26: (`/dev/fssX`), the filesystem you want to snapshot and the place of the 
   27: snapshot file (which can even lie on the filesystem it is snapshotting). 
   28: So, if you want to create a snapshot of filesystem `/`, you would e.g. 
   29: enter:
   31:     # fssconfig -c fss0 / /root/backup
   33: Then you get a snapshot in `/root/backup`. You can then mount that 
   34: snapshot somewhere, and in that mount, you have a view of the filesystem 
   35: at the point of creating the snapshot:
   37:     # mount /dev/fss0 /mnt
   39: When you are done with the snapshot, you unmount it and unconfigure the snapshot:
   41:     # umount /dev/fss0
   42:     # fssconfig -u fss0
   44: ## How to use snapshots?
   46: To use a snapshot, you just configure it again with the same parameters 
   47: as the first time, but now without creating it:
   49:     # fssconfig fss0 / /root/backup
   50:     # mount /dev/fss0 /mnt
   52: If you want to use the snapshot only once, you can use the option `-x` 
   53: when creating it. Then the snapshot will only be available for this one 
   54: single time, and is deleted afterwards.
   56:     # fssconfig -cx fss0 / /root/backup
   58: ## Usage example
   60: What is this even good for if I can't even write to it?
   61: You can use it e.g. for saving files before doing an upgrade or other 
   62: critical changes. When the upgrade goes wrong, you just have to copy 
   63: back the files from the snapshot to the real filesystem.
   65: So, all in all, an example of how to use a snapshot to save and rescue a 
   66: system:
   68:     # fssconfig -c fss0 / /root/backup
   69: 	# fssconfig -u fss0
   70: 	# rm /etc/rc.conf
   71: 	# shutdown -r now
   72: 	[...system will not start again, but drop you to a single-user shell...]
   73: 	# mount -o rw /
   74: 	# fssconfig -x fss0 / /root/backup # The snapshot will be deleted afterwards.
   75: 	# mount /dev/fss0 /mnt
   76: 	# cp /mnt/etc/rc.conf /etc/rc.conf
   77: 	# shutdown -r now
   78: 	[be happy about the login prompt again]

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb