Skip to content

Instantly share code, notes, and snippets.

@jordanlewis
Created October 11, 2021 22:29
Show Gist options
  • Save jordanlewis/4e4fa1ff34e09ebbcfd658268ece773d to your computer and use it in GitHub Desktop.
Save jordanlewis/4e4fa1ff34e09ebbcfd658268ece773d to your computer and use it in GitHub Desktop.
Example userfile workflow
-- Create database
create database mydb;
use mydb;
create table foo (i int primary key);
insert into foo select * from generate_series(1, 100);
create database backups;
-- Backup:
use backups;
backup database mydb to 'userfile://backups.userfiles/backup1' as of system time '-10s';
-- Get the backup:
cockroach userfile get --url $PGURL 'userfile://backups.userfiles/backup1' ~/backup1
-- Run a local cockroach node:
cockroach start-single-node --external-io-dir=~/backup1 --advertise-addr localhost --insecure &
-- Restore into the local cockroach node
restore database mydb from 'nodelocal://0/backup1';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment