| Les deux révisions précédentes Révision précédente | |
| macos:time_machine_via_terminal [27/06/2019 14:27] – Martin | macos:time_machine_via_terminal [27/06/2019 14:28] (Version actuelle) – Martin |
|---|
| Time Machine is a great tool for ensuring that your data is safe, and it's pretty [[http://www.macworld.com/article/1164963/mac_basics_how_to_set_up_time_machine.html|easy to set up and use (en)]]. But for some users, the basic Time Machine interface isn't enough. As with most of OS X's functions, there is a command-line tool that lets you do many things with Time Machine. Here's how you can use the ''tmutil'' command to control and tweak Time Machine from Apple's command-line tool, Terminal. | Time Machine is a great tool for ensuring that your data is safe, and it's pretty [[http://www.macworld.com/article/1164963/mac_basics_how_to_set_up_time_machine.html|easy to set up and use (en)]]. But for some users, the basic Time Machine interface isn't enough. As with most of OS X's functions, there is a command-line tool that lets you do many things with Time Machine. Here's how you can use the ''tmutil'' command to control and tweak Time Machine from Apple's command-line tool, Terminal. |
| |
| ==== Les bases ==== | ===== Les bases ===== |
| {{:macos:terminal-100032775-medium.png?nolink&200 |}} | {{:macos:terminal-100032775-medium.png?nolink&200 |}} |
| Most people won't need to use this command for their backups because the Time Machine interface will suffice. Who will need it? People who want to manage remote Macs or who want to run scripts containing commands for Time Machine. | Most people won't need to use this command for their backups because the Time Machine interface will suffice. Who will need it? People who want to manage remote Macs or who want to run scripts containing commands for Time Machine. |
| <code bash>tmutil stopbackup</code> | <code bash>tmutil stopbackup</code> |
| |
| ==== Save disk space on your laptop ==== | ===== Save disk space on your laptop ===== |
| |
| Since your laptop isn't always connected to its backup disk, Time Machine retains "local snapshots," or files that it will copy to your backup disk the next time it is available. However, these local snapshots take up space, and you may want to turn this feature off if you don't have much room on your hard disk. You can do so with the following command: | Since your laptop isn't always connected to its backup disk, Time Machine retains "local snapshots," or files that it will copy to your backup disk the next time it is available. However, these local snapshots take up space, and you may want to turn this feature off if you don't have much room on your hard disk. You can do so with the following command: |
| If you love delving into the nitty-gritty, and especially if you manage remote Macs, you'll find this to be a very useful tool. | If you love delving into the nitty-gritty, and especially if you manage remote Macs, you'll find this to be a very useful tool. |
| |
| ==== Exclude files and folders ==== | ===== Exclude files and folders ===== |
| |
| You can exclude certain files and folders from your Time Machine backups from the Time Machine pane in System Preferences. Naturally, you can also do this from the command line, too. Run this command: | You can exclude certain files and folders from your Time Machine backups from the Time Machine pane in System Preferences. Naturally, you can also do this from the command line, too. Run this command: |
| The ''tmutil addexclusion'' command has an interesting property: it's sticky. When you use this command, the item you exclude remains in the Time Machine exclusion list even if you move it, which is not the case when you exclude items from the Time Machine preference pane. If you use the above command with the ''-p'' flag, then it will not be sticky, and will be the same as an exclusion you add from the Time Machine preference pane. | The ''tmutil addexclusion'' command has an interesting property: it's sticky. When you use this command, the item you exclude remains in the Time Machine exclusion list even if you move it, which is not the case when you exclude items from the Time Machine preference pane. If you use the above command with the ''-p'' flag, then it will not be sticky, and will be the same as an exclusion you add from the Time Machine preference pane. |
| |
| ==== Manage remote backups ==== | ===== Manage remote backups ===== |
| |
| If you're managing a remote Mac, such as a server, you may want to change Time Machine settings for that computer. You can start by finding where Time Machine backups are stored. Run this command: | If you're managing a remote Mac, such as a server, you may want to change Time Machine settings for that computer. You can start by finding where Time Machine backups are stored. Run this command: |
| Replace ''_volume_name_'' with the name of the disk or volume you want to use. You can add multiple destinations as well, since Time Machine can rotate its backups on several disks or volumes. See ''man tmutil'' for more on setting up multiple backup destinations. (You can now do this without the command line too, see [[http://www.macworld.com/article/2026503/how-to-create-redundant-time-machine-backups.html|How to create redundant Time Machine backups.]]) | Replace ''_volume_name_'' with the name of the disk or volume you want to use. You can add multiple destinations as well, since Time Machine can rotate its backups on several disks or volumes. See ''man tmutil'' for more on setting up multiple backup destinations. (You can now do this without the command line too, see [[http://www.macworld.com/article/2026503/how-to-create-redundant-time-machine-backups.html|How to create redundant Time Machine backups.]]) |
| |
| ==== Get Time Machine stats ==== | ===== Get Time Machine stats ===== |
| |
| Time Machine saves a lot of backups: one per hour for the past 24 hours; one a day for the past week; and one a week before that. You can get a list of all the backups on your Time Machine disk with this command: | Time Machine saves a lot of backups: one per hour for the past 24 hours; one a day for the past week; and one a week before that. You can get a list of all the backups on your Time Machine disk with this command: |