1

So I want to create automatic backups of my home folder without connecting an external disk. This definitely seems like a feature that the mac should have. I understand that if you have Time Machine set up, then it will make local backups as space permits. Well thats exactly what I want. But you need an external disk in order to activate time machine at all.

I don't have an external disk right now. What I can't understand is why I can't just have it make local backups as space permits without connecting an external drive? Since I don't own an external drive there is no way for me to "turn on" time machine. Does anyone know a way I can?

The best case scenario is that I could select one or a few folders to backup, not the entire file system.

The reason for this is that I am programmer, and I move around a lot, and I'm always working on the command line. Working on code in specific work folders. Code files are generally not huge, and I am not wanting to backup every file on my computer, but only my important files that I've worked on many hours. While I try to be as careful as possible and use version control, sometimes I make a mistake and it would be great to just have a local backup of, say, yesterday's file system, or any recent backup.

Thanks.

Macbook Pro 2018 Mojave

  • 1
    why don't you use iCloud and sync required files locally from your Mac to iCloud? – Udhy Nov 25 '19 at 16:33
  • 1
    Just a quick thought, I use SuperDuper (in addition to Time Machine, just in case) and it would be easy to use that (or other backup app) to backup your vital data to a disk image (for example) in any location, and on any schedule you want. – Steve Chambers Nov 25 '19 at 16:48
  • Hi @Udhy as far as i know this only allows Documents and Desktop folder, and also wouldn't be quick as robust as time machine. However it is something i could look into. However i think we can agree that syncing isn't the same as backing up (creating a snap shot at some point in time). – jeffery_the_wind Nov 25 '19 at 16:51
3

If you want a local backup you can run a bash script that creates an archive of your home directory.

zip -r pathToBackup.zip /Users/username

This can be expanded upon with bash to:

  • Add password protection and encryption with the --encrypt option
  • Run automatically at certain times with cron
  • Append timestamps to name of backup file
  • Keep only a certain number of backups
  • etc...
  • Thanks a lot, don't know why I didn't think of this. Could make a script to do the work for me, automate with cron. Not a bad idea, thank you. – jeffery_the_wind Nov 25 '19 at 18:12
2

Even without having configured Time Machine, you can manually create a localsnapshot with the command tmutil snapshot. So setting up a scheduled task to run this command should be straightforward.

There's no point or need to specify which folders to backup: like TM, snapshots only record the changes made to the disk. So if you work on a handful of files, only those files will take up space. (Even the first snapshot doesn't duplicate all your files, it's just an archive of the file catalog.)

Of course, it's worth pointing out that saved versions on the same disk are NOT a backup. Because if your storage volume fails, or the data somehow gets over-written, or your laptop gets stolen, catches fire, etc: you've got nothing.

1

You could use rsync and append a suffix with the date and time as described in this SO answer Use rsync for backup without overwrite

For example (you would change the source and destination directories)

rsync -aE --backup --suffix=`date +'.%F_%H-%M'` ~/Documents/WantedFiles/ ~/Documents/Backup/

This will copy everything (including extended attributes which is the Eswitch) from

~/Documents/WantedFiles/ to ~/Documents/Backups/

The first time files are copied they do not have suffixes.

A1398% mkdir ~/Documents/WantedFiles
A1398% touch ~/Documents/WantedFiles/File1
A1398% touch ~/Documents/WantedFiles/File2
A1398% rsync -aE --backup --suffix=`date +'.%F_%H-%M'` ~/Documents/WantedFiles/ ~/Documents/Backup/
A1398% ls -la ~/Documents/Backup/
total 0
drwxr-xr-x   4 hali  staff  128 Nov 25 19:09 .
drwx------+ 27 hali  staff  864 Nov 25 19:09 ..
-rw-r--r--   1 hali  staff    0 Nov 25 19:09 File1
-rw-r--r--   1 hali  staff    0 Nov 25 19:09 File2

If you change a file and rerun rsync the existing file will be renamed with date and time appended and the new file copied. See the change to File1 here :

A1398% echo 'change' > ~/Documents/WantedFiles/File1
A1398% rsync -aE --backup --suffix=`date +'.%F_%H-%M'` ~/Documents/WantedFiles/ ~/Documents/Backup/
A1398% ls -la ~/Documents/Backup/
total 8
drwxr-xr-x   5 hali  staff  160 Nov 25 19:10 .
drwx------+ 27 hali  staff  864 Nov 25 19:09 ..
-rw-r--r--   1 hali  staff    7 Nov 25 19:10 File1
-rw-r--r--   1 hali  staff    0 Nov 25 19:09 File1.2019-11-25_19-10
-rw-r--r--   1 hali  staff    0 Nov 25 19:09 File2

As only changed files are updated you could schedule it to run daily or hourly as you wish.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .