echemi logo
Product
  • Product
  • Supplier
  • Inquiry
    Home > How to make a full system backup with tar command?

    How to make a full system backup with tar command?

    • Last Update: 2020-04-03
    • Source: Internet
    • Author: User
    Search more information of high quality chemicals, good prices and reliable suppliers, visit www.echemi.com
    It is advisable to make a full backup after installing and setting up the server, so as to avoid reconfiguration when recovering data Although Linux has many backup tools, many administrators still like the old standard because it is more flexible and offers more options "Tar" is a very precise and effective command It's easy to type commands into a text file, making it a shell script Of course, you also need to create a folder to place the backup files We will use a separate directory to avoid including it in the backup file Enter the following command: ා CD/ # mkdir backups #CD backups then use the nano editor to create a shell script file with the following command: ා nano fullserver.sh and enter the following command in it (don't forget the period at the end of the command): tar - cvpf / backups / fullbackup Tar - Directory = / – exclude = proc – exclude = sys – exclude = dev / PTS – exclude = backups The above command uses multiple lines to facilitate reading In the editor you can enter everything on one line After entering, do not forget to save the file (ctrl-x) C option to create a backup file The V option gives more detailed output when the command is executed You can not choose this one, which will not affect security The P option retains file and directory permissions The f option needs to be put at the end because it lets you specify the backup file name and location after the command This instance uses the / backups / fullbackup.tar file #The - Directory option tells tar to switch to the root of the file system before starting the backup #– exclude is to exclude specific files during backup, because these directories are generated dynamically by the system In addition, you need to exclude the directory that contains the backup file Many tar descriptions on the network give exclusion examples as follows: ා - exclude = / proc however, doing so often results in the exclusion directory being still included in the backup, because the directory name should not be preceded by a slash / symbol If you use the above command, tar will back up the proc directory In addition to placing backup files, the / backups directory places your script files The script should be executable before running You can use the following two commands: Chmod 750 / backups / fullserver.sh / backups / fullserver.sh to restore a backup package, you need to copy it to the highest number of files In this article, for example, the - Directory option tells tar to start the backup from the root of the file system, so this is where the decompression begins The command is very simple, just use x instead of C: tar - xvpf / fullbackup.tar has a backup Although it is good, if the hard disk itself has problems, the backup will be lost Therefore, it is best to save backup files to different devices to ensure security If you want to further compress the file, you can use the following command tar - zcvpf / backups / fullbackup Tar GZ - Directory = / - exclude = proc – exclude = sys – exclude = dev / PTS – exclude = backups Similarly, the extracted file becomes: tar - zxvpf / fullbackup.tar.gz
    This article is an English version of an article which is originally in the Chinese language on echemi.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or complaint, to service@echemi.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.

    Contact Us

    The source of this page with content of products and services is from Internet, which doesn't represent ECHEMI's opinion. If you have any queries, please write to service@echemi.com. It will be replied within 5 days.

    Moreover, if you find any instances of plagiarism from the page, please send email to service@echemi.com with relevant evidence.