Annotation of wikisrc/tutorials/how_to_use_snapshots.mdwn, revision 1.1

1.1     ! jdf         1: # How to use snapshots with NetBSD
        !             2: 
        !             3: Snapshots using fss(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.
        !             7: 
        !             8: ## What is a snapshot?
        !             9: 
        !            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.
        !            14: 
        !            15: ## What is a snapshot not?
        !            16: 
        !            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.
        !            21: 
        !            22: ## How to create snapshots?
        !            23: 
        !            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:
        !            30: 
        !            31:     # fssconfig -c fss0 / /root/backup
        !            32: 
        !            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:
        !            36: 
        !            37:     # mount /dev/fss0 /mnt
        !            38: 
        !            39: When you are done with the snapshot, you unmount it and unconfigure the snapshot:
        !            40: 
        !            41:     # umount /dev/fss0
        !            42:     # fssconfig -u fss0
        !            43: 
        !            44: ## How to use snapshots?
        !            45: 
        !            46: To use a snapshot, you just configure it again with the same parameters 
        !            47: as the first time, but now without creating it:
        !            48: 
        !            49:     # fssconfig fss0 / /root/backup
        !            50:     # mount /dev/fss0 /mnt
        !            51: 
        !            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.
        !            55: 
        !            56:     # fssconfig -cx fss0 / /root/backup
        !            57: 
        !            58: ## Usage example
        !            59: 
        !            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.
        !            64: 
        !            65: So, all in all, an example of how to use a snapshot to save and rescue a 
        !            66: system:
        !            67: 
        !            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]
        !            79: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb