How to back up and restore Core Data contents while preserving relationships

I am creating a memo app for iOS with Swift + Core Data. I want to back up and restore Core Data contents while preserving relationships. but, I don't know how to do that. Could you tell me how to backup and restore the relationship while maintaining it? Thank you.

What have you tried? What issues have you encountered?

Generally speaking, the most straightforward way to back up a Core Data store is to make a copy of its file(s), which would then contain all of the data, including all of the relationships.

If you can explain a little more about your use case, that might also help to suggest a solution.

Hardware and software Configuration

MacOS Ventura 13.4.1 (c)

Xcode 15.0 beta 4

Minimum Deployments 12.4

I want my app's users to be able to perform backups to save and restore data.

I didn't know there is a way that back up a Core Data store is to make a copy of its file(s).

I would like to know how to backup to my app's Document folder so that the user can save the backup to their PC.

How to back up and restore Core Data contents while preserving relationships
 
 
Q