Summary of Ubuntu backup methods (four types)

Summary of Ubuntu backup methods (four types)

Method 1:

To use respin, follow these steps:

sudo add-apt-repository ppa:sergiomejia666/respin
sudo apt-get update
sudo apt-get install respin
sudo respin backup backup.iso

Method 2:

1. Download:

Go to http://www.filewatcher.com and download the corresponding package according to your system version:

First is remastersys_3.0.4-2_all.deb
Then choose 1 of the following application packages to download based on your system version (you can skip the GUI package if you don't need a graphical interface):

remastersys-gui_3.0.4-1_i386.deb (32-bit)
remastersys-gui_3.0.4-1_amd64.deb (64-bit)

2. Installation:

First, enter sudo apt-get install plymouth-x11 in the command line. If an error occurs due to lack of support, change to: sudo apt-get -f install
If sudo apt-get -f install fails, you need to modify source.list. The first method is: 1. Open "Ubuntu Software Center" on the right side of the computer - 2. Double-click to enlarge - 3. Find "Edit" in the upper left corner - 4. Select "Software Source" and the "Software and Updates Window" will pop up - 5. Select "Other Sites" in the "Ubuntu Software" item - 6. You can choose the best server, or you can directly select a source you think is fast on the left. I personally like mirrors.163.com - 7. Close after completion - 8. Run sudo apt-get -f install again
The second method is: 1. First search the Internet for sources suitable for your Ubuntu version - 2. Open the terminal and enter the command sudo gedit /etc/apt/sources.list - 3. Add directly - 4. Save and close - 5. Enter sudo get-apt update to update and then enter sudo dpkg -i remastersys_3.0.4-2_all.deb
After the installation is complete, choose 1 from the following codes based on your system version (skip if you don’t need a graphical interface):
sudo dpkg -i remastersys-gui_3.0.4-1_i386.deb (32 bit)
sudo dpkg -i remastersys-gui_3.0.4-1_amd_64.deb (64 bit)

3. Open the software:

sudo remastersys-gui (with GUI interface) or sudo remastersys (without GUI interface)

4. Start backup:

Here is a detailed explanation of what each option means
sudo remastersys backup - creates a liveCD/DVD backup of the system, which contains your home directory by default
sudo remastersys backup custom.iso - creates a backup of the system liveCD/DVD and names it custom.iso, which contains your personal directory by default
sudo remastersys clean - clear the temporary directory. If you have made an iso before, you can run this option first. Otherwise, it is not necessary.
sudo remastersys dist - creates a distribution ISO image containing your personal directory
sudo remastersys dist cdfs - create a distribution ISO image without your personal directory
sudo remastersys iso custom.iso——Create a distribution ISO image containing your personal directory and name it custom.iso, where custom can be changed to any name you want

Generally we choose sudo remastersys backup custom.iso

5. Finish:

You can find the CD image you want to create in /home/remastersys/remastersys. Copy the image and run the test in the virtual machine. After trying the first two methods, I found that it can be perfectly solved for small-capacity Ubuntu systems. However, when I backed up the system, it was more than 20G. After backing up with the above two methods, an error was reported as follows: "The compressed filesystem is larger than genisoimage allows for a single file." According to feedback from netizens: "The 4GB limit is an iso9660 specification, which exists in the cdrtools fork and the genisoimage in Debian and Ubuntu." Therefore, you can try methods three and four.

Method 3:

First become the root user: Enter sudo su in the command line
If there is no root user: Enter ssudo passwd in the command line to set the password and then enter the root directory of the file system (of course, if you do not want to back up the entire file system, you can also enter the directory you want to back up, including remote directories or directories on mobile hard drives): cd /

Here is the complete command I used to backup my system:

# tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Let's take a quick look at this command:

"tar" is of course the program we use to back up our systems.
"cvpfz" is a tar option that means "create archive", "keep permissions" (keep everything as it was), and "use gzip to reduce file size".
"backup.gz" is the file name of the archive file we are going to get.
"/" is the directory we want to back up, in this case the entire file system.

The directories that must be excluded from the backup are given between the archive file name "backup.gz" and the directory name to be backed up "/". Some directories are useless, such as "/proc", "/lost+ found", "/sys". Of course, the archive file "backup.gz" itself must be excluded, otherwise you may get some unexpected results. If you do not exclude "/mnt", other partitions mounted on "/mnt" will also be backed up. In addition, you need to confirm that nothing is mounted on "/media" (such as a CD, mobile hard disk). If something is mounted, you must exclude "/media" as well.
Someone might suggest you to exclude the "/dev" directory, but I think this is a bad idea, and I won't discuss the specific reasons here.
Before executing the backup command, please confirm whether the command you typed is what you want. The backup command may take a while to execute.
After the backup is complete, a file named "backup.tgz" will be generated in the root directory of the file system, and its size may be very large. Now you can burn it to a DVD or put it somewhere you deem safe.

At the end of the backup command you may see a message like this: 'tar: Error exit delayed from previous errors', in most cases you can ignore it.
You can also use Bzip2 to compress files. Bzip2 has a higher compression ratio than gzip, but is slower. If compression is important to you, you should use Bzip2, replace the "z" in the command with "j", and give the archive the correct extension "bz2". The complete command is as follows:

# tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

Restore System:

Be careful when restoring your system! If you don't know what you are doing, you may lose important data, so be careful!
Continuing with the example above. Switch to the root user and copy the file "backup.tgz" to the root directory of the partition.
One of the wonderful things about Linux is that you can restore a system from a running system without having to boot it specifically with a boot-cd. Of course, if your system is already frozen and cannot be booted, you can boot it from a Live CD and the effect will be the same. You can also use a command to kill all the files in a Linux system, but I am not going to give you that command here!

Use the following command to restore the system:

# tar xvpfz backup.tgz -C /

If your archive is compressed using Bzip2, you should use:

# tar xvpfj backup.tar.bz2 -C /

NOTE: The above command will overwrite all files on the partition with the files from the archive.

Before executing the recovery command, please confirm whether the command you typed is what you want. It may take a long time to execute the recovery command.

When the restore command is finished, your work is not done yet. Don't forget to recreate the directories that were excluded during the backup:

# mkdir proc
# mkdir lost+found
# mkdir mnt
# mkdir sys

etc.

When you restart your computer, you'll find that everything is back to the way it was when you created the backup!

Method 4:

Use Ubuntu's built-in backup tool:

1. Click on Settings in the upper right corner
2. System Settings
3. Backup
4. Select the folder to save
5. Select the folders you want to ignore
6. Select storage location
7. Click Backup in the Overview
8. Finally, use the archive command: tar -cvf file.tar.gz /home/test/* (/home/test/* means all the items in the test folder under your home directory, file.tar.gz is the file you want to generate. After generation, it will be in the directory where you execute the command. The specific directory can be displayed by executing the pwd command.)

reduction:

1. First copy the archive file to a location on the system, make sure the remaining space is at least twice the size of the file, then unzip it to the current directory
2.cd to the current directory
3.tar -xvf filename.tar.bz2 ./ (If you are not extracting to the current folder, please remember to add "-C", such as: tar -xvf filename.tar.bz2 -C /home/)
4. Finally, use the system's built-in backup tool to restore

If the original password error appears after recovery and restart (copy the archive file to another Ubuntu system to restore it back to this problem, either set the same username and password as the original system, or perform the following steps):

1. Turn on your computer and press the Esc key immediately when the "Press Esc to enter grub message" appears on the screen.
2. Then three options will appear, select "recovery mode" and press Enter (as shown in Figure 1).
3. Your computer will enter the shell from startup. When the command prompt appears, enter "passwd username". Here username is your user name. If you even forget your user name, don't worry, there is a way. You can first enter "ls /home" to check the user name, and then enter the above command.
4. When the prompt appears, you can directly enter your new password and confirm it again.
5. Then enter "shutdown -r now" to restart your computer and log in with your new password.

Summarize

The above is a summary of the Ubuntu backup method introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  How to use Dayjs to calculate common dates in Vue

>>:  Solve the problem that the service cannot be started when installing the decompressed version of mysql 5.7.18 winx64 on Win7 x64

Recommend

Native JS implementation of loading progress bar

This article shares a dynamic loading progress ba...

Mysql transaction isolation level principle example analysis

introduction You must have encountered this in an...

How to use Navicat to export and import mysql database

MySql is a data source we use frequently. It is v...

Example of making XML online editor using js

Table of contents Preface The need for online XML...

Summary of methods for inserting videos into HTML pages

Now if you want to use the video tag in a page, y...

How MySQL Select Statement is Executed

How is the MySQL Select statement executed? I rec...

How to use Linux tr command

01. Command Overview The tr command can replace, ...

Detailed example of deploying Nginx+Apache dynamic and static separation

Introduction to Nginx dynamic and static separati...

Use jQuery to fix the invalid page anchor point problem under iframe

The application scenario is: the iframe page has n...

Detailed tutorial on using Docker to build Gitlab based on CentOS8 system

Table of contents 1. Install Docker 2. Install Gi...

Understanding and solutions of 1px line in mobile development

Reasons why the 1px line becomes thicker When wor...