Backup user's metadatas?

I want to export and backup the user’s data in the database (contacts, calendars, circles, others configs ; but not files) so I can suppress them, and be able to restore the few of them that will ask. Is there an application and occ comands for that ?

I don’t think there is a way export parts of the database.

There are ways to access some of the items you described using WebDAV (curl or some script) but this requires user auth - in other words you can only access you own data but not data from others.

here is a thread about contacts - but again only for the user himself:

Regarding contacts and calendars you could use calcardbackup

Most of the things can only be used in restore with the same Nextcloud version (e.g. circles, configs, …). You can only dump the database and not backup the files. Ok there are file information in the database, too. On restore you can restore the database without the user files. You can restore files (or not) from another source and then use
sudo -u www-data php /path/to/nextcloud/occ files:scan --all
to re-read the restored files in the empty Nextcloud.

Thank for your answers…

I have a backup of the database, but it will not work or will be very complicate if I want to restore just one or a very few users in some monthes, when I will use another version of Nextcloud. I want a file to restore by user.

There is “User migration” that could do the job. It propose choose to save user’s setup, profile info, contacts, agendas, other’s apps specific configs (forms…) and files.
It might be possible to do this for any user, by impersonate them… Big Job !

Is there occ commands for migration and impersonate apps ; and is it possible to make a script to automaticate that ?