sqlite-jdbc-crypt icon indicating copy to clipboard operation
sqlite-jdbc-crypt copied to clipboard

Backup and Restore command should take ciphers parameters

Open Willena opened this issue 5 years ago • 0 comments

When you're trying to backup the database using the "backup to " non standard command, the destination database is opened clear all the time. If the source is encrypted you might want to keep your backup encrypted or encrypt it with another cipher algorithm. The "backup to" command should provide a way to choose the algorithm parameters like when the user opens the database.

The same thing apply for the "restore from" command.

Possible workaround ( not tested ):

You can try putting cipher parameters after the name like when you're opening the database. Ex:

  • Backup to file:dB.db?key=AA
  • Backup to dB.db?key=AA

If that doesn't work you can still cipher it after backup using the standard way:

  • open the new database clear ( do not specify the key at the end.
  • execute the "PRAGMA key='...'" SQL query to apply a key to the database.
  • close the database

After that it should be now encrypted.

If you want to restore the database, might need to rekey the backup before restore

  • open with ciphers parameters
  • execute PRAGMA rekey=''
  • close the database
  • do the restore

Rekeying the backup might be also needed since at this stage it is clear

  • PRAGMA rekey='mykey'

Another workaround would be to:

  1. open the database
  2. dump it as sql file
  3. execute the sql file in a new database

Willena avatar Jun 21 '19 08:06 Willena