Skip to content

WIP: users: Implement backup/restore

Veiko Aasa requested to merge vexch/freedombox:users-backup-restore into main

While reviewing !2340 (closed), I got some additional ideas and decided to make a separate MR.

I did some code quality improvements and made additional changes:

  • Restore all 3 user related Plinth database tables in one SQL transaction.
  • Use CSV files with headers when taking SQLite backups.
  • Backup/restore Samba users database using tdbbackup/tdbrestore utilities from tdb-tools package. This allows backing up Samba users database without stopping Samba server and disconnecting active Samba shares. Also it allows easier backup content debugging to see what users are included in Samba users database.
  • Don't restart slapd and nslcd services during backup. As the documentation says, slapcat is safe to run on mdb databases while slapd is running. This change avoids possible issues where user accounts are not available for example while user's crontab tasks run during backup process.
  • Don't backup full LDAP schema and configs. Those are possible to reset by running User's module setup().
  • Don't backup user home directories. Those may contain gigabytes of data and can affect backup/restore stability. I think there should be some other option/way to backup home folders.
  • Add functional tests for backup/restore.

Todo:

  • Backup/restore user's authorized_keys file.
  • Add password confirmation to restore Users module data from backup (or when restoring any app?).
  • Invalidate all Plinth sessions after restore?
  • Handle already existing user directories when restoring backup. (Rename/delete existing user folders if user uid-s don't match?)

Closes #2051.

Edited by Veiko Aasa

Merge request reports

Loading