Ubuntu system backup and restore

Source: Internet
Author: User
Tags uuid

http://xing.rocks/2015/03/06/ubuntu%E7%B3%BB%E7%BB%9F%E5%A4%87%E4%BB%BD%E4%B8%8E%E8%BF%98%E5%8E%9F/

Some time ago the computer out of the problem, to change the computer to work, to build a perfect working environment on Ubuntu System is very laborious, and there is a website being done. Therefore, the entire system needs to be backed up.
Ubuntu system Backup does not yet have a good software, but because everything in Linux is a file, you can simply package a system with tar. There are some good examples on the internet, such as the blog of the past. If the tar error is in the backup, you can exclude the specific folder according to the prompt information. In addition, you can turn off services such as MySQL before you backup, preventing the program from running and causing errors during backup. This article records the errors and workarounds that occurred during the restore process.

First, the backup system
12 Sudo-star CPZPF ubuntu.tgz--exclude=/proc--exclude=/lost+found--exclude=ubuntu.tgz--exclude= /mnt--exclude=/sys--exclude=/home/xing/virtualbox\ vms/--exclude=/home/xing/.cache/

Parameters:

    • -C: Create a parameter directive for a compressed file (the meaning of Create)
    • -P: Use original file properties (attributes are not changed according to user)
    • -Z: Properties with gzip, which uses gzip compression
    • -V: Files are displayed during compression
    • -F: Using file name
    • -P: Use absolute path to compress
    • -exclude file: Excluded Files directory
      Remember that the wrong file directories are excluded from the packaging process
Second, restore system

After installing the new system, first backup/boot and/etc/fstab, the former is recorded boot boot selection information, the latter recorded the
The partition mounts the information and changes it to be unable to enter the system.
Then copy the ubuntu.tgz to the root directory and run the command:

12 sudo- star xvpfz ubuntu.tgz-c/

Finally, restore the backup/boot and/etc/fstab

Third, partition mount

First time inexperienced, restore without backing up the Fstab file, resulting in unable to boot after the original user's mount point disappears, unable to
Enter the system, so rewrite the fstab file again. After booting into the login screen, press CTRL+ALT+F1 to enter the background, and then
It can be manipulated with root privileges.

1. First, view the partition information and disk type:
12 sudo fdisk- l sudo blkid

2. Then, modify according to the/etc/fstab format

The configuration file contains the following items:

File system, mount point, type, options, dump, pass

    • System: Partition positioning, UUID For example:/dev/sda5 is uuid=f00318bf-f572-4b9d-adcf-5d583c449b08
    • Mount point: Location of specific mount points, for example:/boot
    • Type: Disk types, Linux partitions are generally ext4,windows partitions are generally NTFS
    • Options: Mount parameters, typically defaults
    • Dump: Disk backup, default = 0, no backup
    • Pass: Disk check, default = 0, no check
3. Finally, check that the mount is successful
1 sudo mount -A

If there is no problem, the big success, landing again can enter the desktop.

Four, MySQL reset password

With a few days down, Apache, GBrowse, and even QQ International version can run very well, at present only found that MySQL in the terminal landing error:
Access denied for user ' root ' @ ' localhost ' (using password:yes). It could have been a backup when MySQL was running, causing some files to be lost or wrong.
You cannot change the password using Mysqladmin. Finally found a way to refer to the MySQL Access denied for user [email protected] Error Resolution summary
Here's how:

123456789 Service MySQL Stopmysqld_safe--user=mysql--skip-grant-tables--skip-networking &mysql-u root mysqlmysql> UPDATE user SET password=password (' newpassword ') where user=' root '; mysql> FLUSH privileges;mysql> quitservice restartmysql-uroot-penter Password: < Enter new password newpassword>

One of the core is the parameter -skip-grant-tables, that is, do not use the password can also login Mysql;-user
=mysql is running as a MySQL user,-skip-networking is only running locally and does not have to listen on the network port. Then you can
The MySQL table changed the user password, and finally landed successfully.

Ubuntu system backup and restore

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.