Dump / Restore entire case studies.

mfdb_cs_dump(mdb, out_location)
mfdb_cs_restore(mdb, in_location)

Arguments

mdb

(required) A database connection created by mfdb()

in_location, out_location

(required) A filesystem directory or '.tar.gz' file to dump / restore database contents.

Details

Deprecated: These commands aren't strictly necessary any more. In most situations it will be easier to use Postgres' pg_dump and pg_restore. See mfdb-package for some examples of how to do it. These functions don't offer much more functionality and much slower.

mfdb_cs_dump copies all data from the database/case-study that mdb is connected to, and writes it out to files in out_location. If this ends with 'tar.gz', then all files will be put into a tarball with the name

mfdb_cs_restore will remove any case-study data, and replaces it with the content of in_location, a directory or tarball.

Value

NULL

Examples

# Copy data from one database to another, note they don't have to be the same type
mdb_out <- mfdb(tempfile(fileext = '.sqlite'))
#> 2022-11-16 12:34:27 INFO:mfdb:Creating schema from scratch
#> 2022-11-16 12:34:27 INFO:mfdb:Taxonomy market_category no updates to make
#> 2022-11-16 12:34:27 INFO:mfdb:Schema up-to-date
mdb_in <- mfdb(tempfile(fileext = '.duckdb'))
#> 2022-11-16 12:34:27 INFO:mfdb:Creating schema from scratch
#> 2022-11-16 12:34:27 INFO:mfdb:Taxonomy market_category no updates to make
#> 2022-11-16 12:34:28 INFO:mfdb:Schema up-to-date

dump_path <- tempfile(fileext='.tar.gz')
mfdb_cs_dump(mdb_out, dump_path)
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table institute
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table bait_type
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table net_type
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table gear
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table vessel_type
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table vessel_owner
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table market_category
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table sex
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table maturity_stage
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table species
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table areacell
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table stomach_state
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table digestion_stage
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table sampling_type
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table population
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table data_source
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table index_type
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table port
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table trip
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table tow
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table vessel
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table case_study
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table survey_index
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table division
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table sample
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table predator
#> 2022-11-16 12:34:28 INFO:mfdb:Dumping table prey
mfdb_cs_restore(mdb_in, dump_path)
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table institute
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table bait_type
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table net_type
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table gear
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table vessel_type
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table vessel_owner
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table market_category
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table sex
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table maturity_stage
#> 2022-11-16 12:34:28 INFO:mfdb:Restoring table species
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table areacell
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table stomach_state
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table digestion_stage
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table sampling_type
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table population
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table data_source
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table index_type
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table port
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table trip
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table tow
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table vessel
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table case_study
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table survey_index
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table division
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table sample
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table predator
#> 2022-11-16 12:34:29 INFO:mfdb:Restoring table prey

mfdb_disconnect(mdb_in)
mfdb_disconnect(mdb_out)