[backup] allowing to specify the Timeshift mode: rsync or btrfs

This commit is contained in:
Vinicius Moreira
2020-04-28 18:29:30 -03:00
parent f860be1b07
commit 636469215c
6 changed files with 17 additions and 6 deletions

View File

@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.9.2] 2020 ## [0.9.2] 2020
### Improvements
- Backup
- new **type** field on settings to specify the Timeshift backup mode: **RSYNC** or **BTRFS**
### UI ### UI
- icons, buttons and colors changes - icons, buttons and colors changes

View File

@@ -288,7 +288,7 @@ backup:
uninstall: null # defines if the backup should be performed before uninstalling a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation uninstall: null # defines if the backup should be performed before uninstalling a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation
upgrade: null # defines if the backup should be performed before upgrading a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation upgrade: null # defines if the backup should be performed before upgrading a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation
downgrade: null # defines if the backup should be performed before downgrading a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation downgrade: null # defines if the backup should be performed before downgrading a package. Allowed values: null (a dialog will be displayed asking if a snapshot should be generated), true: generates the backup without asking. false: disables the backup for this operation
type: rsync # defines the Timeshift backup mode -> 'rsync' (default) or 'btrfs'
``` ```
#### Tray icons #### Tray icons
Priority: Priority:

View File

@@ -57,7 +57,8 @@ def read_config(update_file: bool = False) -> dict:
'uninstall': None, 'uninstall': None,
'downgrade': None, 'downgrade': None,
'upgrade': None, 'upgrade': None,
'mode': 'incremental' 'mode': 'incremental',
'type': 'rsync'
} }
} }

View File

@@ -302,6 +302,7 @@ class GenericSettingsManager:
core_config['backup']['enabled'] = bkp_form.get_component('enabled').get_selected() core_config['backup']['enabled'] = bkp_form.get_component('enabled').get_selected()
core_config['backup']['mode'] = bkp_form.get_component('mode').get_selected() core_config['backup']['mode'] = bkp_form.get_component('mode').get_selected()
core_config['backup']['type'] = bkp_form.get_component('type').get_selected()
core_config['backup']['install'] = bkp_form.get_component('install').get_selected() core_config['backup']['install'] = bkp_form.get_component('install').get_selected()
core_config['backup']['uninstall'] = bkp_form.get_component('uninstall').get_selected() core_config['backup']['uninstall'] = bkp_form.get_component('uninstall').get_selected()
core_config['backup']['upgrade'] = bkp_form.get_component('upgrade').get_selected() core_config['backup']['upgrade'] = bkp_form.get_component('upgrade').get_selected()
@@ -447,8 +448,14 @@ class GenericSettingsManager:
], ],
max_width=default_width, max_width=default_width,
id_='mode') id_='mode')
type_ = self._gen_select(label=self.i18n['type'].capitalize(),
tip=None,
value=core_config['backup']['type'],
opts=[('rsync', 'rsync', None), ('btrfs', 'btrfs', None)],
max_width=default_width,
id_='type')
sub_comps = [FormComponent([enabled_opt, mode, install_mode, uninstall_mode, upgrade_mode, downgrade_mode], spaces=False)] sub_comps = [FormComponent([enabled_opt, mode, type_, install_mode, uninstall_mode, upgrade_mode, downgrade_mode], spaces=False)]
return TabComponent(self.i18n['core.config.tab.backup'].capitalize(), PanelComponent(sub_comps), None, 'core.bkp') return TabComponent(self.i18n['core.config.tab.backup'].capitalize(), PanelComponent(sub_comps), None, 'core.bkp')
def _gen_select(self, label: str, tip: str, id_: str, opts: List[tuple], value: object, max_width: int, type_: SelectViewType = SelectViewType.RADIO): def _gen_select(self, label: str, tip: str, id_: str, opts: List[tuple], value: object, max_width: int, type_: SelectViewType = SelectViewType.RADIO):

View File

@@ -9,5 +9,5 @@ def delete_all_snapshots(root_password: str) -> SimpleProcess:
return SimpleProcess(['timeshift', '--delete-all', '--scripted'], root_password=root_password) return SimpleProcess(['timeshift', '--delete-all', '--scripted'], root_password=root_password)
def create_snapshot(root_password: str) -> SimpleProcess: def create_snapshot(root_password: str, mode: str) -> SimpleProcess:
return SimpleProcess(['timeshift', '--create', '--scripted'], root_password=root_password) return SimpleProcess(['timeshift', '--create', '--scripted', '--{}'.format(mode)], root_password=root_password)

View File

@@ -144,7 +144,7 @@ class AsyncAction(QThread, ProcessWatcher):
return False return False
self.change_substatus('[{}] {}'.format(i18n['core.config.tab.backup'].lower(), i18n['action.backup.substatus.create'])) self.change_substatus('[{}] {}'.format(i18n['core.config.tab.backup'].lower(), i18n['action.backup.substatus.create']))
created, _ = handler.handle_simple(timeshift.create_snapshot(root_pwd)) created, _ = handler.handle_simple(timeshift.create_snapshot(root_pwd, app_config['backup']['type']))
if not created and not self.request_confirmation(title=i18n['core.config.tab.backup'], if not created and not self.request_confirmation(title=i18n['core.config.tab.backup'],
body='{}. {}'.format(i18n['action.backup.error.create'], body='{}. {}'.format(i18n['action.backup.error.create'],