24 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
9a4905e832
backups: Use privileged decorator for backup actions
Tests:

- DONE: Functional tests works
- DONE: Initial setup works
  - DONE: Borg repository is created at /var/lib/freedombox/borgbackup
- DONE: With regular and with encrypted repository
  - DONE: Creating a repository works
  - DONE: Getting information works. When adding a existing location, incorrect
    password leads to error in the add form.
  - DONE: Listing archives works
  - DONE: Creating/restoring an archive works
    - DONE: Backup manifest is created in /var/lib/plinth/backups-manifests/
    - DONE: Including an app that dumps/restores its settings works
  - DONE: Exporting an archive as tar works
    - DONE: Exporting a large archive yields reasonable download speeds. 31
      MB/s. 1GB file in about 30 seconds.
  - DONE: Restoring from an uploaded archive works
  - DONE: Listing the apps inside an archive works before restore
- DONE: Errors during operations are re-raises as simpler errors
  - DONE: Get info
  - DONE: List archives
  - DONE: Delete archive (not handled)
  - FAIL: Export tar
  - DONE: Init repo
  - DONE: Get archive apps (not handled)

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:53:57 -04:00
Sunil Mohan Adapa
01e00cdde4
backups: Allow comments to be added to archives during backup
Tests performed:

- Schedules are able to store and retrieve comments properly. Information about
schedule backups stored in comments is extracted properly.

- Unit tests run.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-01-21 20:33:47 -05:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Sunil Mohan Adapa
7467fa4553
backups: Separate repository loading from instantiation
The constructor of the Repository object is being used for two distinct
purposes. One is to load the object from database and other to instantiate it
with parameter such that it can be saved to database. Separating the two usages
to different methods simplifies code and parameter passing for consumers.

Also turn some class specific constants from globals to class constants.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-09-07 12:52:49 -04:00
Sunil Mohan Adapa
5b01689a92
backups: Clarify two separate uses of name create_repository
It is being used to mean initialize the borg repository as well as creating an
instance of the repository class object. Use 'initialize' for former and
'get_instance' for latter.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-09-07 12:52:46 -04:00
Sunil Mohan Adapa
d05bbab751
backups: Rename repo_path to borg_path for clarity
borg_path clearly signifies that it is to be used by borg and consumers of the
class will not be confused by it.

Also rename some repo_path variables in test cases.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-09-07 12:52:36 -04:00
Sunil Mohan Adapa
dd5d93637f
backups: Don't send passphrase on the command line
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-07-03 12:44:54 +05:30
Joseph Nuthalapati
3a6dcbe7a7
Verify SSH hostkey before mounting
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-07-03 12:42:41 +05:30
Sunil Mohan Adapa
2d832ace36
backups: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-05-12 17:13:22 +05:30
Sunil Mohan Adapa
039461b846
backups: yapf fixes
Reviewed-by: Michael Pimmer <info@fonfon.at>
2018-12-11 23:38:30 +01:00
Sunil Mohan Adapa
f4b0c4dc9f
backups: Don't fail tests when borg is not installed
When a user running tests is root and borg is not installed, several tests fail
due to missing borg. Skip these tests when borg is not installed.

Reviewed-by: Michael Pimmer <info@fonfon.at>
2018-12-11 23:37:38 +01:00
Michael Pimmer
bb95229a91
Backups: unittests for accessing repository with borg directly
- adapt action and write tests for accessing a borg repo directly
  via borg+ssh, without mounting it
- some docstring updates

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-13 18:28:51 -05:00
Michael Pimmer
fc9e406bf8
Backups: allow using keyfile as credentials for sshfs mounts
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-13 18:28:44 -05:00
Michael Pimmer
eab8991b54
Backups: support for encrypted repositories
- implement download, restore, delete archives of encrypted
  repositories
- change how BorgRepository and SshBorgRepository handle path
- when/before creating remote repositories, check whether the
  connection works
- updated tests

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-13 18:28:17 -05:00
Michael Pimmer
c223250569
Backups: remove unittests to backups test directory
And add one bugfix to reset cfg.actions_dir after changing it

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-13 18:28:00 -05:00
Joseph Nuthalapati
26764b7370
backups: Rename test_backup to test_api
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-03 19:18:48 -04:00
Michael Pimmer
d8fc2057d4
Backup module: added some unittests; minor doc updates
- added unittests
- introduced function backups.get_location_path()
- minor docstring / comment and naming updates

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-01 07:01:03 -04:00
Joseph Nuthalapati
670f58019e
backups: Minor styling fixes
- More descriptive iteration variables
- Run yafp, isort

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:46:39 +05:30
Joseph Nuthalapati
dc781b03fa
backups: Make getting all apps method public
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:46:18 +05:30
James Valleroy
94a1b37700
backups: Add more basic tests for backups API
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:43:53 +05:30
James Valleroy
3681985f40
backups: Patch actions for shutdown services test
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:41:23 +05:30
James Valleroy
9554a34cce
backups: Fix and test service shutdown and restore
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:41:12 +05:30
James Valleroy
52ab0b54c6
backups: Implement process manifests for Packet
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:40:29 +05:30
James Valleroy
d0581243aa
backups: Fix iteration over loaded modules
Add tests for affected functions.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-09-24 19:39:55 +05:30