Prevent your project from getting catastrophically obliterated beyond repair [Unity Essentials]

I was careful not to put the magic Eeeeew word in the title: BACKUP! :face_with_hand_over_mouth:

Soooooooooooooo often someone stops by and we can only ask: did you make a backup? You do have a backup, right? :face_in_clouds:

Seriously, frickinā€™ seriously, just do it! Close your project, copy it elsewhere or zip it up. At least daily. Donā€™t overwrite the previous archive, keep several. Thatā€™s the bare minimum solution!

But other than that, once you really, seriously put some effort in where you work on a project that you intend to work on for months and hopefully will publish, then be sure to ā€¦

Use Version Control

What version control does for you is NOT the same as a backup! Instead, it keeps a record of every frickinā€™ change you ever made!

Provided you check in often and in small doses, it becomes easy to debug issues. Particularly the nasty ones. You can ā€œgo back in timeā€ and see how the two-days-old version of the project behaves and whether it has the same issue.

Although itā€™s rarely needed because more often than not, you can just scroll through the changelist, view the changes you made, only to realize: ā€œOh right, I changed that thing here!ā€. Quite often thatā€™s all you need to know.

The most commonly used VCS are Unity Version Control and GitHub (git). For git, itā€™s best to use a GUI tool like GitHub Desktop or SourceTree.

The terminology and workflow can be offputting, so I wouldnā€™t recommend using source control as an absolute beginner. It does however become mandatory when working with other people on the same project. To that end, a word of ā€¦

CAUTION: Do not Cloud Sync your project!

Cloud sync, any form, be it SomeDrive or SomeBox, all share the same principal flaw when sharing files: they can be overwritten, or synchronization fails to complete and you start working with an incomplete set of files.

For individual documents thatā€™s easy to spot. For a complex Unity project this can be disastrous and quickly lead to loss of work, possibly even corrupting scenes or the entire project without recovery (unless you have a BACKUP :shushing_face:).

This can happen even to a solo user - but for two users, youā€™re almost certainly going to destroy each otherā€™s work. Hence why you need Version Control!

Cloud Backup? Live Backup?

Ugh, isnā€™t cloud drive sync a backup? Yes, but NO!

A cloud drive will typically sync every changed file asap. However, a single file change while you still have unsaved data in memory means the cloud version of the project may not actually be fully functional. It keeps changing between the state of completely synced and ā€œcorruptā€ so to speak. On top, it keeps synchronizing even the temporary cache files that Unity generates which are typically several times larger than your Assets folder.

For that reason, no matter how or where you make a backup, it is absolutely crucial to close the project before you start the backup. And you donā€™t open it again until the backup is complete. This is why any backup tool that runs on a schedule is not suitable to backup your Unity projects either! Unless you can set it up so that the backup runs when you arenā€™t using the Unity editor, such as when the computer shuts down.

Ideally, just like Version Control, you exclude certain subfolders from the backup to save on time and disk space. At least: Library, Obj, Temp, Build or Builds.

Poor Manā€™s Backup

In its simplest form, you can simply use 7-Zip to create an archive of the project folder. You can relatively easily write a batch or bash script to back up each project.

Preferably choose uncompressed or with low compression because this will be a lot faster (like several times!). Be sure to exclude the folders mentioned above or else the backup will take significantly longer too.

2 Likes

Some more thoughts for backing up:

Charging your phone on a computer is a great time to upload it to your phoneā€™s drive. If youā€™re ever at someoneā€™s house that doesnā€™t mind putting up with your gamdev idiosyncrasies, you can make a backup on their computer/ laptop using your phone.

Google drive gives 15 gigs free space if you have a google email account.

Any random USB drives you have lying around or external hard drives of course.

Also if your project is super huge, sometimes it makes sense to backup everything but the art ,and place that in a specific super huge folder, that way youā€™re not backing up 15 gigs of stuff every day even when youā€™re just doing code.

Good job @CodeSmile, I am happy to see this kind of guidance about backing up projects, because itā€™s too often neglected.

Iā€™d like to share my own solution that might be helpfulā€¦

Poor Manā€™s Easier Backup :wink:

You can use Export Project to Zip to make backups directly from the Unity Editor (no need to quit Unity or to close your project!)
To use it, simply add it to your project and go to File > Export Project to Zip
Itā€™s free and works on both Mac and PC.
It makes smaller backup files and itā€™s faster because it doesnā€™t include the Library folder (which is usually the largest folder, but not required to get a perfectly working backup!)