MCPcopy Index your code
hub / github.com/fastmonkeys/stellar / restore

Function restore

stellar/command.py:89–129  ·  view source on GitHub ↗

Restores the database from a snapshot

(name)

Source from the content-addressed store, hash-verified

87@stellar.command()
88@click.argument('name', required=False)
89def restore(name):
90 """Restores the database from a snapshot"""
91 app = get_app()
92
93 if not name:
94 snapshot = app.get_latest_snapshot()
95 if not snapshot:
96 click.echo(
97 "Couldn't find any snapshots for project %s" %
98 load_config()['project_name']
99 )
100 sys.exit(1)
101 else:
102 snapshot = app.get_snapshot(name)
103 if not snapshot:
104 click.echo(
105 "Couldn't find snapshot with name %s.\n"
106 "You can list snapshots with 'stellar list'" % name
107 )
108 sys.exit(1)
109
110 # Check if slaves are ready
111 if not snapshot.slaves_ready:
112 if app.is_copy_process_running(snapshot):
113 sys.stdout.write(
114 'Waiting for background process(%s) to finish' %
115 snapshot.worker_pid
116 )
117 sys.stdout.flush()
118 while not snapshot.slaves_ready:
119 sys.stdout.write('.')
120 sys.stdout.flush()
121 sleep(1)
122 app.db.session.refresh(snapshot)
123 click.echo('')
124 else:
125 click.echo('Background process missing, doing slow restore.')
126 app.inline_slave_copy(snapshot)
127
128 app.restore(snapshot)
129 click.echo('Restore complete.')
130
131
132@stellar.command()

Callers

nothing calls this directly

Calls 7

get_appFunction · 0.85
load_configFunction · 0.85
get_latest_snapshotMethod · 0.80
get_snapshotMethod · 0.80
inline_slave_copyMethod · 0.80
restoreMethod · 0.80

Tested by

no test coverage detected