backend: Use th backup URL in backup-cli and add snapshot type to FileBackend

This commit is contained in:
Christian Decker
2020-04-04 16:20:46 +02:00
parent c58e675877
commit 4c146bf2a4
3 changed files with 31 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from backup import FileBackend
from backup import FileBackend, get_backend
import os
import click
import json
@@ -7,10 +7,10 @@ import json
@click.command()
@click.argument("lightning-dir", type=click.Path(exists=True))
@click.argument("backup-dir", type=click.Path(exists=True))
def init(lightning_dir, backup_dir):
destination = 'file://' + os.path.join(backup_dir, 'backup.dbak')
backend = FileBackend(destination)
@click.argument("backend-url")
def init(lightning_dir, backend_url):
destination = backend_url
backend = get_backend(destination)
backend.version, backend.prev_version = 0, 0
backend.offsets = [512, 0]
backend.version_count = 0
@@ -23,6 +23,8 @@ def init(lightning_dir, backup_dir):
'backend_url': destination,
}))
# TODO Take a snapshot
print("Initialized backup backend {destination}, you can now start c-lightning".format(
destination=destination,
))