Creating Automatic Period local backup of folder

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


Solution 1:

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...

Solution 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.