Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Root user check
- if [[ $EUID -ne 0 ]]; then
- echo You must be root to execute this script!
- exit 1
- fi
- SNAPS=.snapshots
- SNAPS_DIR=/$SNAPS
- # Snaps folder check
- if [ ! -d $SNAPS_DIR ]; then
- mkdir $SNAPS_DIR
- fi
- btrfs_backup_func(){
- DEST=$1
- CONFIG=$2
- custom_echo "$DEST ($CONFIG) backup started"
- # If it already exists, remove it first
- if btrfs subvolume list / | grep $SNAPS/$CONFIG; then
- btrfs subvolume delete $SNAPS_DIR/$CONFIG
- fi
- btrfs subvolume snapshot -r $DEST $SNAPS_DIR/$CONFIG \
- || custom_echo "ERROR! Check the output."
- custom_echo "$DEST ($CONFIG) backup terminated"
- custom_echo "Location: $SNAPS_DIR/$CONFIG"
- }
- custom_echo(){
- echo -e "\033[1;36m==> $*\033[0m"
- }
- # HOME
- btrfs_backup_func /home home
- # Empty line
- echo
- # ROOT
- btrfs_backup_func / root
- echo
- echo
- # Print all subvolumes
- custom_echo "BTRFS updated subvolumes list:"
- btrfs subvolume list /
Add Comment
Please, Sign In to add comment