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-06-16 21:48:42.353486 INFO:mfdb:Creating schema from scratch
#> 2026-06-16 21:48:42.438251 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-06-16 21:48:42.523565 INFO:mfdb:Schema up-to-date
mdb_in <- mfdb(tempfile(fileext = '.duckdb'))
#> 2026-06-16 21:48:42.596806 INFO:mfdb:Creating schema from scratch
#> 2026-06-16 21:48:43.145193 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-06-16 21:48:43.667667 INFO:mfdb:Schema up-to-date

dump_path <- tempfile(fileext='.tar.gz')
mfdb_cs_dump(mdb_out, dump_path)
#> 2026-06-16 21:48:43.669807 INFO:mfdb:Dumping table institute
#> 2026-06-16 21:48:43.671475 INFO:mfdb:Dumping table bait_type
#> 2026-06-16 21:48:43.672616 INFO:mfdb:Dumping table net_type
#> 2026-06-16 21:48:43.673694 INFO:mfdb:Dumping table gear
#> 2026-06-16 21:48:43.675332 INFO:mfdb:Dumping table vessel_type
#> 2026-06-16 21:48:43.676571 INFO:mfdb:Dumping table vessel_owner
#> 2026-06-16 21:48:43.677646 INFO:mfdb:Dumping table market_category
#> 2026-06-16 21:48:43.678706 INFO:mfdb:Dumping table sex
#> 2026-06-16 21:48:43.679847 INFO:mfdb:Dumping table maturity_stage
#> 2026-06-16 21:48:43.68104 INFO:mfdb:Dumping table species
#> 2026-06-16 21:48:43.685822 INFO:mfdb:Dumping table areacell
#> 2026-06-16 21:48:43.686975 INFO:mfdb:Dumping table stomach_state
#> 2026-06-16 21:48:43.688195 INFO:mfdb:Dumping table digestion_stage
#> 2026-06-16 21:48:43.689387 INFO:mfdb:Dumping table sampling_type
#> 2026-06-16 21:48:43.690452 INFO:mfdb:Dumping table population
#> 2026-06-16 21:48:43.691541 INFO:mfdb:Dumping table data_source
#> 2026-06-16 21:48:43.692634 INFO:mfdb:Dumping table index_type
#> 2026-06-16 21:48:43.6938 INFO:mfdb:Dumping table port
#> 2026-06-16 21:48:43.694847 INFO:mfdb:Dumping table trip
#> 2026-06-16 21:48:43.695954 INFO:mfdb:Dumping table tow
#> 2026-06-16 21:48:43.697105 INFO:mfdb:Dumping table vessel
#> 2026-06-16 21:48:43.698174 INFO:mfdb:Dumping table case_study
#> 2026-06-16 21:48:43.699374 INFO:mfdb:Dumping table survey_index
#> 2026-06-16 21:48:43.700429 INFO:mfdb:Dumping table division
#> 2026-06-16 21:48:43.701475 INFO:mfdb:Dumping table sample
#> 2026-06-16 21:48:43.702656 INFO:mfdb:Dumping table predator
#> 2026-06-16 21:48:43.703762 INFO:mfdb:Dumping table prey
mfdb_cs_restore(mdb_in, dump_path)
#> 2026-06-16 21:48:43.819014 INFO:mfdb:Restoring table institute
#> 2026-06-16 21:48:44.014967 INFO:mfdb:Restoring table bait_type
#> 2026-06-16 21:48:44.016464 INFO:mfdb:Restoring table net_type
#> 2026-06-16 21:48:44.017356 INFO:mfdb:Restoring table gear
#> 2026-06-16 21:48:44.212188 INFO:mfdb:Restoring table vessel_type
#> 2026-06-16 21:48:44.412723 INFO:mfdb:Restoring table vessel_owner
#> 2026-06-16 21:48:44.414062 INFO:mfdb:Restoring table market_category
#> 2026-06-16 21:48:44.414788 INFO:mfdb:Restoring table sex
#> 2026-06-16 21:48:44.605113 INFO:mfdb:Restoring table maturity_stage
#> 2026-06-16 21:48:44.804795 INFO:mfdb:Restoring table species
#> 2026-06-16 21:48:45.010122 INFO:mfdb:Restoring table areacell
#> 2026-06-16 21:48:45.011646 INFO:mfdb:Restoring table stomach_state
#> 2026-06-16 21:48:45.207355 INFO:mfdb:Restoring table digestion_stage
#> 2026-06-16 21:48:45.403225 INFO:mfdb:Restoring table sampling_type
#> 2026-06-16 21:48:45.40478 INFO:mfdb:Restoring table population
#> 2026-06-16 21:48:45.405682 INFO:mfdb:Restoring table data_source
#> 2026-06-16 21:48:45.406453 INFO:mfdb:Restoring table index_type
#> 2026-06-16 21:48:45.60053 INFO:mfdb:Restoring table port
#> 2026-06-16 21:48:45.601961 INFO:mfdb:Restoring table trip
#> 2026-06-16 21:48:45.602899 INFO:mfdb:Restoring table tow
#> 2026-06-16 21:48:45.60384 INFO:mfdb:Restoring table vessel
#> 2026-06-16 21:48:45.604623 INFO:mfdb:Restoring table case_study
#> 2026-06-16 21:48:45.797224 INFO:mfdb:Restoring table survey_index
#> 2026-06-16 21:48:45.7988 INFO:mfdb:Restoring table division
#> 2026-06-16 21:48:45.799628 INFO:mfdb:Restoring table sample
#> 2026-06-16 21:48:45.800795 INFO:mfdb:Restoring table predator
#> 2026-06-16 21:48:45.801795 INFO:mfdb:Restoring table prey

mfdb_disconnect(mdb_in)
mfdb_disconnect(mdb_out)