Last active
February 14, 2019 02:06
-
-
Save yelizariev/798667efd9a618178f572d7707da6e64 to your computer and use it in GitHub Desktop.
backup disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.ubuntu.com/community/BackupYourSystem/TAR | |
# Archive | |
tar -cvpzf backup.tar.gz --one-file-system / | |
# Restore | |
sudo tar -xvpzf /path/to/backup.tar.gz -C /media/whatever --numeric-owner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-disk | |
# and https://www.linuxquestions.org/questions/linux-general-1/how-to-mount-img-file-882386/ | |
# remote backup | |
ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz | |
# mounting | |
# * unzip the image.gz to image.img | |
gunzip < image.gz > image.img | |
# * calculate offset | |
fdisk -l image.img | |
# Check for start start sector and sector size. Multiply those, e.g. 2048 * 512 | |
sudo mount -o loop,offset=1048576 image.img /path/to/mount-point/ | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot | |
# https://ubuntuforums.org/showthread.php?t=1692144 | |
sudo mount /dev/sda1 /mnt | |
sudo mount --bind /dev /mnt/dev | |
sudo mount --bind /proc /mnt/proc | |
sudo mount --bind /sys /mnt/sys | |
sudo chroot /mnt | |
update-grub | |
sudo grub-install /dev/sda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment