Ubuntu backup and restore

Detailed tutorial

Ubuntu can back up the system as a tar compressed file, and it can also easily restore the system from this file.

Backup###

Our goal is to back up / directory, but not back up /home, and /proc, /sys, /mnt, /media, /run, /dev
To achieve this, execute the following command

cd / 
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /

among them
--Exclude=/example/path: path of files or directories that do not need to be backed up
--One-file-system: This command can automatically exclude /home, and /proc, /sys, /mnt, /media, /run, /dev.
/: The partition that needs backup

restore###

Enter livecd, use gparted tool to partition and format the hard disk
Then mount the partition you want to recover
Usually mounted under /mnt
Then use the following command to restore

sudo mount /dev/sda2 /mnt
sudo tar -xvpzf /path/to/backup.tar.gz -C /mnt --numeric-owner
- - numeric-owner - This option tells tar to restore the numeric owners of the files in the archive, rather than matching to any user names in the environment you are restoring from. This is due to that the user id:s in the system you want to restore don't necessarily match the system you use to restore(eg a live CD).

Fix grub

sudo su
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts 
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
grub-install --recheck /dev/sda
update-grub
umout

exit
sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt


Recommended Posts

Ubuntu backup and restore
How to backup and restore Redis data on Ubuntu 14.04
Ubuntu20.04 experience and beautification
[python] python2 and python3 under ubuntu
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
Jmeter (18)_Ubuntu deploy jmeter and ant
ubuntu install and configure GitLab
Ubuntu deployment and experience Nexus3
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Ubuntu PostgreSQL installation and configuration
systemback ubuntu system backup and recovery is simple, fast and effective
Ubuntu creates users adduser and useradd
The difference between CentOS and Ubuntu
Ubuntu environment variables and ADB configuration
Netweaver and Windows, Ubuntu data sharing
Install and configure MySQL on Ubuntu
Install and configure Docker in Ubuntu
ubuntu modify and configure ip address
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Install and deploy Gerrit under Ubuntu
Redis installation under ubuntu and windows
Install nodejs and npm under Ubuntu 16.04
Ubuntu change password and username steps
Protect your eyes (ubuntu and chrome)
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Ubuntu upgrade software and ubuntu upgrade system commands
Ubuntu common instructions and usage details
Ubuntu18.04 installation Anaconda3 and VSCode guide
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Ubuntu configuration source and installation software
Compile and install QEMU under Ubuntu
Windows Ubuntu subsystem ssh and ftp
Linux basics (Ubuntu copy and paste)
FreeFileSync: Compare and synchronize files in Ubuntu
ubuntu Docker installation and deployment of Rancher
Install Gnome and VNC on Ubuntu Server
Ubuntu installation and deployment Redash operation notes (2020.08)
Linux development preparation-install VMware and run Ubuntu
51 MCU program development and download under Ubuntu
[Daily] Win10 open and install ubuntu subsystem
Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation
Installation and uninstallation of CUDA under Ubuntu 16.04
Install docker on ubuntu and basic usage
Ubuntu19.10 compile and run C language program
Ubuntu18.04 Server version installation and use (graphic)
Installation and deployment of Nginx in Ubuntu
Install fonts on Ubuntu and switch default fonts
Ubuntu 18.04 source code compile and install ffmpeg4.1
Ubuntu install PHP and PHP Nginx configuration method
Deploy python3 and nginx projects on ubuntu18.04
The relationship between Open3D version and Ubuntu
Ubuntu 14.04 16.04 Linux nvidia driver download and installation
Linux install Docker and run Ubuntu system
Ubuntu install ftp server and possible problems
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
M5Stack is developed and compiled on ubuntu
How to install Ubuntu20.04 and install NVIDIA driver
Configure node js and npm under Ubuntu 14.04