TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SwiftData Book - Add Backup Procedure.

Forums > Swift

I think a good addition for the SwiftData book would be how to handle a backup of the user's data.

Currently in the book we see how to get the current url, but not how to do a backup. A simple file copy won't work becuase the default configuration uses 3 files, the main, journal and wal files.

If you want to make a backup of the user's data, what would be the correct procedure?

In CoreData you can open a file with the vacum option, to reduce the file size, also you can open the file with the journal delete option, to concentrate all the data into a single file. Currently in SwiftData I don't see a way to do that.

3      

Simply backup the 3 files. No need to merge the wal file into the sqlite file.

Regardless of whether you are backing up one file or three, it is essential that you ensure that no software can write to the database during the backup.

(Incidentally, none of the books I own on Core Data mentions backups.)

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.