UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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 Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free 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.