BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

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      

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.