SHARE
TWEET

snapshot+systemupdate.sh

a guest Nov 26th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Snapshot + System Update
  3. # ---------------------------
  4. # Snapshot - Rollback - Btrfs
  5. # ---------------------------
  6.  
  7. BTRFS=/usr/bin/btrfs
  8. CP=/usr/bin/cp
  9. ECHO=/usr/bin/echo
  10. GREP=/usr/bin/grep
  11. MOUNT=/usr/bin/mount
  12. MV=/usr/bin/mv
  13. PIKAUR=/usr/bin/pikaur
  14. PACMAN=/usr/bin/pacman
  15. REFLECTOR=/usr/bin/reflector
  16. SED=/usr/bin/sed
  17. SUDO=/usr/bin/sudo
  18. CHECKUPDATES=/usr/bin/checkupdates
  19.  
  20. # ---------------------------
  21. #      Snapshot System
  22. # ---------------------------
  23. if $CHECKUPDATES >/dev/nul 2>/dev/null ; then
  24. bootstate=`$MOUNT | $GREP "on / type btrfs" | $GREP "subvol=/@snapshots/TESTING"`
  25. if [ -z $"{bootstate}" ]
  26.     then
  27.         $ECHO ""
  28.         $ECHO $bootstate
  29.         $ECHO ""
  30.         $ECHO "System ist nicht mit TESTING hochgefahren !"
  31.         $ECHO "ENDE !"
  32.         exit
  33.     else
  34.         # -------- make new OLDSTABLE --------
  35.         $SUDO $BTRFS subvolume delete /.snapshots/OLDSTABLE
  36.         $SUDO $MV /.snapshots/STABLE /.snapshots/OLDSTABLE
  37.         $SUDO $SED -i 's/STABLE/OLDSTABLE/g' /.snapshots/OLDSTABLE/etc/fstab
  38.         $SUDO $CP /boot/vmlinuz-linux-stable /boot/vmlinuz-linux-oldstable
  39.         $SUDO $CP /boot/initramfs-linux-stable.img /boot/initramfs-linux-oldstable.img
  40.        
  41.         # --------- make new STABLE ----------
  42.         $SUDO $BTRFS subvolume snapshot / /.snapshots/STABLE
  43.         $SUDO $SED -i 's/TESTING/STABLE/g' /.snapshots/STABLE/etc/fstab
  44.         $SUDO $CP /boot/vmlinuz-linux /boot/vmlinuz-linux-stable
  45.         $SUDO $CP /boot/initramfs-linux.img /boot/initramfs-linux-stable.img
  46.        
  47.         # ---------------------------
  48.         #      Update System
  49.         # ---------------------------
  50.         $SUDO $REFLECTOR --verbose -l 10 -p https --sort rate --save /etc/pacman.d/mirrorlist
  51.         $SUDO $PACMAN -Syu
  52.         # $PIKAUR -Syu # aktualisiert AUR gleich mit :-)
  53.        
  54.         # ---------------------------
  55.         #    Balance Filesystem
  56.         # --------------------------
  57.         $SUDO $BTRFS balance start -dusage=5 /btrfs
  58. fi
  59. else
  60.     echo "Keine Updates vorhanden - ENDE !"
  61.     sleep 2
  62. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top