1
0
Fork 0

Merge remote-tracking branch 'origin/master' into nharrington-forward-creds

master
Neal Harrington 2 years ago
commit d2be7eceb6

@ -1,8 +1,8 @@
# Restoring directly from SQLite # Restoring directly from SQLite
rqlite supports loading a node directly from two sources, either of which can be used to restore from an existing [node backup](https://github.com/rqlite/rqlite/blob/master/DOC/BACKUPS.md): rqlite supports loading a node directly from two sources, either of which can be used to restore from an existing [node backup](https://github.com/rqlite/rqlite/blob/master/DOC/BACKUPS.md):
- An actual SQLite database file. This is the fastest way to initialize a rqlite node from an existing SQLite database. - An actual SQLite database file. This is the fastest way to initialize a rqlite node from an existing SQLite database. Even large SQLite databases can be loaded into rqlite in a matter of seconds. This the recommended way to initialize your rqlite node from SQLi.te
- SQLite dump file. This is another convenient manner to initialize a system from an existing SQLite database. But if your source database is large, it can be slow. - SQL statements in text format. This is another convenient manner to initialize a system from an existing SQLite database (or other database). **But if your source database is large, it can be quite slow.** If you find the restore times to be too long, you should first load the SQL statements directly into a SQLite database, and then restore rqlite using the resulting SQLite database file.
## Examples ## Examples
The following examples show a trivial database being generated by `sqlite3`, the SQLite file being backed up, converted to the corresponding list of SQL commands, and then loaded into a rqlite node listening on localhost using each form. The following examples show a trivial database being generated by `sqlite3`, the SQLite file being backed up, converted to the corresponding list of SQL commands, and then loaded into a rqlite node listening on localhost using each form.
@ -17,10 +17,10 @@ Enter ".help" for usage hints.
sqlite> CREATE TABLE foo (id integer not null primary key, name text); sqlite> CREATE TABLE foo (id integer not null primary key, name text);
sqlite> INSERT INTO "foo" VALUES(1,'fiona'); sqlite> INSERT INTO "foo" VALUES(1,'fiona');
sqlite> sqlite>
# Load directly from the SQLite file. # Load directly from the SQLite file, which is the recommeded process.
~ $ curl -v -XPOST localhost:4001/db/load -H "Content-type: application/octet-stream" --data-binary @restore.sqlite ~ $ curl -v -XPOST localhost:4001/db/load -H "Content-type: application/octet-stream" --data-binary @restore.sqlite
# Convert SQLite database file to set of SQL commands and then load # Convert SQLite database file to set of SQL statements and then load
~ $ echo '.dump' | sqlite3 restore.sqlite > restore.dump ~ $ echo '.dump' | sqlite3 restore.sqlite > restore.dump
~ $ curl -XPOST localhost:4001/db/load -H "Content-type: text/plain" --data-binary @restore.dump ~ $ curl -XPOST localhost:4001/db/load -H "Content-type: text/plain" --data-binary @restore.dump
``` ```
@ -37,7 +37,7 @@ $ rqlite
``` ```
### rqlite CLI ### rqlite CLI
The CLI supports loading from a SQLite database file or dump file. Below shows an example of loading from the former. The CLI supports loading from a SQLite database file or SQL text file. The CLI will automatically detect the type of data being used for the restore operation. Below shows an example of loading from the former.
``` ```
~ $ sqlite3 restore.sqlite ~ $ sqlite3 restore.sqlite
SQLite version 3.22.0 2018-01-22 18:45:57 SQLite version 3.22.0 2018-01-22 18:45:57

Loading…
Cancel
Save