-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsysbackup.sh
executable file
·46 lines (41 loc) · 1.23 KB
/
sysbackup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# sysbackup.sh - Backup root partition to an external drive
# Labels for backup name
host=Veil
distro=gentoo
type=full
date=`date "+%F"`
# Backup destination and full path to the tarball.
backup_dest=/mnt/transcend/SysBackup
backup_file="$backup_dest/$host-$distro-$type-$date.tar.gz"
# Check if the destination exists.
if [ ! -d $backup_dest ]; then
echo "The backup destination is unreachable, aborting..."
exit
fi
# Ask user for confirmation.
echo "Performing full system backup (/ partition only)"
echo ""
echo "Destination: $backup_file"
echo "/dev, /mnt, /opt, /proc, /sys, /tmp, /lost+found and /home will be excluded from this backup."
echo ""
echo "To restore from the backup later, boot into a LiveCD, mount the disk on /mnt/mountpoint,"
echo "cd into the mountpoint and run: tar --xattrs -xvzpf $backup_file -C /mnt/mountpoint"
echo ""
echo -n "Are you ready to backup? (y/n): "
read executeback
# Execute backup.
if [ $executeback == "y" ]; then
sudo tar --xattrs -cvzpf $backup_file\
--exclude=$backup_file\
--exclude=/boot/EFI\
--exclude=/dev\
--exclude=/mnt\
--exclude=/opt\
--exclude=/proc\
--exclude=/sys\
--exclude=/tmp\
--exclude=/lost+found\
--exclude=/home\
/
fi