Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ensure running as root
- if [ "$(id -u)" != "0" ]; then
- exec sudo "$0" "$@"
- fi
- windowsmount=`fdisk -l | grep "Microsoft reserved" | awk -F" " '{print $1}'`
- if [[ $windowsmount == *"nvme"* ]]; then
- windowsmount=${windowsmount::-2};
- else
- windowsmount=${windowsmount::-1};
- fi
- backupname="`hostname`_windows_backup_`date '+%Y-%m-%d'`_.img.gz"
- user=$SUDO_USER
- bash -c "dd status=progress if=$windowsmount | gzip > $backupname ; chown $user:$user $backupname"
- # to restore... something like this:
- # gzip -d -c {backup.img.gz} | dd status=progress of={where}
- # run the restore as root, not sudo
Advertisement
Add Comment
Please, Sign In to add comment