diff --git a/backup/backup.py b/backup/backup.py index 058c47b..1a492f6 100755 --- a/backup/backup.py +++ b/backup/backup.py @@ -299,6 +299,23 @@ def on_db_write(writes, data_version, plugin, **kwargs): kill("Could not append DB change to the backup. Need to shutdown!") +@plugin.init() +def on_init(options, **kwargs): + dest = options.get('backup-destination', 'null') + if dest != 'null': + plugin.log( + "The `--backup-destination` option is deprecated and will be " + "removed in future versions of the backup plugin. Please remove " + "it from your configuration. The destination is now determined by " + "the `backup.lock` file in the lightning directory", + level="warn" + ) + + configs = plugin.rpc.listconfigs() + if not configs['wallet'].startswith('sqlite3'): + kill("The backup plugin only works with the sqlite3 database.") + + def kill(message: str): plugin.log(message) time.sleep(1) diff --git a/backup/test_backup.py b/backup/test_backup.py index 9ef54ff..d385153 100644 --- a/backup/test_backup.py +++ b/backup/test_backup.py @@ -189,3 +189,21 @@ def test_restore(node_factory, directory): rdest = os.path.join(bpath, 'lightningd.sqlite.restore') subprocess.check_call([cli_path, "restore", bdest, rdest]) + + +def test_warning(directory, node_factory): + bpath = os.path.join(directory, 'lightning-1', 'regtest') + bdest = 'file://' + os.path.join(bpath, 'backup.dbak') + os.makedirs(bpath) + subprocess.check_call([cli_path, "init", bpath, bdest]) + opts = { + 'plugin': plugin_path, + 'allow-deprecated-apis': deprecated_apis, + 'backup-destination': 'somewhere/over/the/rainbox', + } + l1 = node_factory.get_node(options=opts, cleandir=False) + l1.stop() + + assert(l1.daemon.is_in_log( + r'The `--backup-destination` option is deprecated and will be removed in future versions of the backup plugin.' + ))