MacOSX system tip: Back up files with rsync

Source: Internet
Author: User
Tags chmod rsync backup

Backup must be a very boring thing, because everyone is reluctant to do it. Often listen to friends say lost mobile phone, bad hard drive, more distressing is-a large number of documents also no longer exist. It may be possible to avoid these disasters by regularly backing up files on a regular basis.

The Mac's own time machine can automatically back up everything including system files, applications, music, photos, movies, and documents. However, if you and I want to choose which content to back up and when to back up, then the MAC built in another backup tool ––rsync, may be more suitable for us.

Command

Rsync is an easy-to-use and powerful command Line Backup tool. She appears in almost all Linux and Unix operating systems, and of course is included in Mac OS X. The command line has been demonized into a complex and tedious relic, and in fact command-line tools (such as rsync) are simply beyond imagination.

You can easily complete a backup of your user's directory by opening the Terminal program in utility and entering the following command:

Rsync-ae--delete--progress ~ "/volumes/backup"

Rsync is the command name;

-ae parameter settings copy files and directories, and maintain access rights, modify the time files such as metadata (metadata);

The--delete parameter makes the target homology consistent, and the files that are deleted in the source directory are also deleted in the destination directory. If you do not include the "--delete" option, files that have been deleted in the source directory will still be saved in the destination directory.

The--progress parameter displays the progress of the replication detail.

~ Represents the current user's home directory, which is the source directory you need to back up;

/volumes/backup/is the destination directory for the backup.

If you are not sure about the effect of the backup, you might want to try running the command with the following parameters:

The-n argument lets the command just run virtual, without actually changing anything;

Script

We can specify different source directories to select what needs to be backed up, while/volumes/backup/an external hard drive as the target media for backup, and obviously you need to make changes based on your own driver name. (You can see the name of the drive on the Finder or desktop, or use the Ls/volumes command in the terminal program to view the list of drives.) To save these commands as a script file with the. command suffix name.

Then, use the following command to give the user permission to run the script file:

chmod u+x ~/documents/tools/backup.command

The chmod command is used to modify permissions on files and directories, and u+x parameters let the owner have permission to execute the file.

Now, as long as you double-click the Backup.command file in the Finder, you can automatically complete the backup of the file.

Automatic

If more automated and periodic backups are required. Open ical, create a new event, specify a "repeat" frequency (such as weekly or monthly), select "Open File" in the "Reminders" section, click "Other ..." in the Drop-down menu, and select the script file for backup in the pop-up dialog box. In the future, the system automatically executes the backup command whenever a specified time arrives.

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.