Linux system backup Restore script

Source: Internet
Author: User

\

#!/bin/SH#备份linux系统. #命令如:SHThe current script.SH/dev/Sdax backup file name # parameter 1: Backup disk, umount before backup. such as:/dev/sda1# parameter 2: Backup saved file name. if[$#-ne2]; Then    Echo "please pass in two parameters. "Exit0fi#当前日期, used to create temporary folders and backup files. Datename=`Date+%y%m%d_%h%m%S ' #临时挂载的文件夹名称tmpdir="/tmp/dir${datename}"mkdir${tmpdir}Mount${1} ${tmpdir} #执行备份Echo "backing up the system! "TarCvpzf ${2}${datename}.tgz–exclude=${tmpdir}/proc–exclude=${tmpdir}/backup–exclude=${tmpdir}/lost+found–exclude=${tmpdir }/mnt–exclude=${tmpdir}/sys ${tmpdir}/Echo "unmount the backup disk! "Umount${tmpdir}Echo "Delete the backup source folder! "rmdir${tmpdir} #参考: http://blog.sina.com.cn/s/blog_48a0f2740100kddw.html# http://blog.csdn.net/shuibinlang/article/details/1731295# http://blog.csdn.net/lanmanck/article/details/6035371# http://www.cnblogs.com/peida/archive/2012/10/24/2737730.html# http://dadekey.blog.51cto.com/107327/119938/# http://blog.163.com/sy1984_5_23/blog/static/419093352009510111929258/
#!/bin/SH#还原linux系统. #命令如:SHThe current script.SH/dev/sdax backup files. tgz# parameter 1: The restored disk, umount before restoring. such as:/dev/sda1# Parameter 2: The restored source file. if[$#-ne2]; Then    Echo "please pass in two parameters. "Exit0fi    Echo "Create a temporary folder. "Datename=`Date+%y%m%d_%h%m%S ' Tmpdir="/tmp/dir${datename}"mkdir${tmpdir}Echo "mount the restore disk. "Mount${1} ${tmpdir} #执行还原Echo "The system is being restored! "TarXVPFZ ${2}-C ${tmpdir}/mkdir${tmpdir}/procmkdir${tmpdir}/lost+foundmkdir${tmpdir}/mntmkdir${tmpdir}/SYSmkdir${tmpdir}/BackupEcho "unmount the backup disk! "Umount${tmpdir}Echo "Delete Temp Folder"rmdir${tmpdir}Echo "Complete System Restore! "#参考: http://blog.sina.com.cn/s/blog_48a0f2740100kddw.html

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.