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'))
#> 2026-04-24 11:51:39.262825 INFO:mfdb:Creating schema from scratch
#> 2026-04-24 11:51:39.3441 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-04-24 11:51:39.42254 INFO:mfdb:Schema up-to-date
mdb_in <- mfdb(tempfile(fileext = '.duckdb'))
#> 2026-04-24 11:51:39.503215 INFO:mfdb:Creating schema from scratch
#> 2026-04-24 11:51:39.957131 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-04-24 11:51:40.495219 INFO:mfdb:Schema up-to-date

dump_path <- tempfile(fileext='.tar.gz')
mfdb_cs_dump(mdb_out, dump_path)
#> 2026-04-24 11:51:40.497373 INFO:mfdb:Dumping table institute
#> 2026-04-24 11:51:40.499007 INFO:mfdb:Dumping table bait_type
#> 2026-04-24 11:51:40.500165 INFO:mfdb:Dumping table net_type
#> 2026-04-24 11:51:40.501271 INFO:mfdb:Dumping table gear
#> 2026-04-24 11:51:40.502939 INFO:mfdb:Dumping table vessel_type
#> 2026-04-24 11:51:40.504164 INFO:mfdb:Dumping table vessel_owner
#> 2026-04-24 11:51:40.505234 INFO:mfdb:Dumping table market_category
#> 2026-04-24 11:51:40.506306 INFO:mfdb:Dumping table sex
#> 2026-04-24 11:51:40.507478 INFO:mfdb:Dumping table maturity_stage
#> 2026-04-24 11:51:40.508663 INFO:mfdb:Dumping table species
#> 2026-04-24 11:51:40.513481 INFO:mfdb:Dumping table areacell
#> 2026-04-24 11:51:40.51469 INFO:mfdb:Dumping table stomach_state
#> 2026-04-24 11:51:40.515905 INFO:mfdb:Dumping table digestion_stage
#> 2026-04-24 11:51:40.517097 INFO:mfdb:Dumping table sampling_type
#> 2026-04-24 11:51:40.518172 INFO:mfdb:Dumping table population
#> 2026-04-24 11:51:40.519234 INFO:mfdb:Dumping table data_source
#> 2026-04-24 11:51:40.520272 INFO:mfdb:Dumping table index_type
#> 2026-04-24 11:51:40.521397 INFO:mfdb:Dumping table port
#> 2026-04-24 11:51:40.522481 INFO:mfdb:Dumping table trip
#> 2026-04-24 11:51:40.523566 INFO:mfdb:Dumping table tow
#> 2026-04-24 11:51:40.524783 INFO:mfdb:Dumping table vessel
#> 2026-04-24 11:51:40.525905 INFO:mfdb:Dumping table case_study
#> 2026-04-24 11:51:40.527079 INFO:mfdb:Dumping table survey_index
#> 2026-04-24 11:51:40.528146 INFO:mfdb:Dumping table division
#> 2026-04-24 11:51:40.529186 INFO:mfdb:Dumping table sample
#> 2026-04-24 11:51:40.530357 INFO:mfdb:Dumping table predator
#> 2026-04-24 11:51:40.531458 INFO:mfdb:Dumping table prey
mfdb_cs_restore(mdb_in, dump_path)
#> 2026-04-24 11:51:40.641184 INFO:mfdb:Restoring table institute
#> 2026-04-24 11:51:40.841642 INFO:mfdb:Restoring table bait_type
#> 2026-04-24 11:51:40.843365 INFO:mfdb:Restoring table net_type
#> 2026-04-24 11:51:40.844194 INFO:mfdb:Restoring table gear
#> 2026-04-24 11:51:41.031663 INFO:mfdb:Restoring table vessel_type
#> 2026-04-24 11:51:41.217933 INFO:mfdb:Restoring table vessel_owner
#> 2026-04-24 11:51:41.219375 INFO:mfdb:Restoring table market_category
#> 2026-04-24 11:51:41.220195 INFO:mfdb:Restoring table sex
#> 2026-04-24 11:51:41.405436 INFO:mfdb:Restoring table maturity_stage
#> 2026-04-24 11:51:41.591138 INFO:mfdb:Restoring table species
#> 2026-04-24 11:51:41.782624 INFO:mfdb:Restoring table areacell
#> 2026-04-24 11:51:41.783927 INFO:mfdb:Restoring table stomach_state
#> 2026-04-24 11:51:41.970449 INFO:mfdb:Restoring table digestion_stage
#> 2026-04-24 11:51:42.160455 INFO:mfdb:Restoring table sampling_type
#> 2026-04-24 11:51:42.161907 INFO:mfdb:Restoring table population
#> 2026-04-24 11:51:42.162806 INFO:mfdb:Restoring table data_source
#> 2026-04-24 11:51:42.16355 INFO:mfdb:Restoring table index_type
#> 2026-04-24 11:51:42.354386 INFO:mfdb:Restoring table port
#> 2026-04-24 11:51:42.355972 INFO:mfdb:Restoring table trip
#> 2026-04-24 11:51:42.356967 INFO:mfdb:Restoring table tow
#> 2026-04-24 11:51:42.357955 INFO:mfdb:Restoring table vessel
#> 2026-04-24 11:51:42.358799 INFO:mfdb:Restoring table case_study
#> 2026-04-24 11:51:42.552176 INFO:mfdb:Restoring table survey_index
#> 2026-04-24 11:51:42.553607 INFO:mfdb:Restoring table division
#> 2026-04-24 11:51:42.554445 INFO:mfdb:Restoring table sample
#> 2026-04-24 11:51:42.555618 INFO:mfdb:Restoring table predator
#> 2026-04-24 11:51:42.556557 INFO:mfdb:Restoring table prey

mfdb_disconnect(mdb_in)
mfdb_disconnect(mdb_out)