File System Snapshots - Paiet/Tech-Journal-for-Everything GitHub Wiki

  1. Install Snapper
    • yum install snapper
  2. Create a thin provisioned LV storage pool
    • lvcreate --thin vg1/pool1 --size 500G
  3. Create LV that will require snapshots and mount it
    • lvcreate --thin vg1/pool1 --virtualsize 50G --name website
    • mkfs.ext4 /dev/vg1/website
    • mkdir /website
    • mount /dev/vg1/website /website
    • semanage fcontext -a -t httpd_sys_content_t /website
    • restorecon /website
  4. Create a Snapper configuration file
    • snapper --c website create-config --f "lvm(ext4)" /website
    • less /etc/sysconfig/snapper
    • less /etc/snapper/configs/website
    • ls -la /website
      • Look for .snapshots folder
  5. Take a snapshot prior to a change
    • snapper --c website create --t pre
  6. Take a snapshot after making the change
    • snapper --c website create --t post --pre-num 1
    • Is assigned a snapshot number, but it still tied to the "pre" snapshot
    • Use snapper --c website list to determine snapshot number
  7. View the files that changed
    • snapper --c website status 1..2
    • c = File changed
    • + = File added
    • - = File deleted
  8. View the actual differences in a file
    • snapper --c website diff 1..2 /website/index.html
  9. Undo changes
    • Individual file
      • snapper -c website -v undochange 1..2 /website/index.html
    • The entire snapshot
      • snapper -c website -v undochange 1..2
  10. Delete snapshots
    • snapper -c website delete 1
    • snapper -c website delete 2