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-01-25 17:20:51.665177 INFO:mfdb:Creating schema from scratch
#> 2026-01-25 17:20:51.753035 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-01-25 17:20:51.838156 INFO:mfdb:Schema up-to-date
mdb_in <- mfdb(tempfile(fileext = '.duckdb'))
#> 2026-01-25 17:20:51.917327 INFO:mfdb:Creating schema from scratch
#> 2026-01-25 17:20:52.333055 INFO:mfdb:Taxonomy market_category no updates to make
#> 2026-01-25 17:20:52.878464 INFO:mfdb:Schema up-to-date

dump_path <- tempfile(fileext='.tar.gz')
mfdb_cs_dump(mdb_out, dump_path)
#> 2026-01-25 17:20:52.88048 INFO:mfdb:Dumping table institute
#> 2026-01-25 17:20:52.88204 INFO:mfdb:Dumping table bait_type
#> 2026-01-25 17:20:52.88326 INFO:mfdb:Dumping table net_type
#> 2026-01-25 17:20:52.884441 INFO:mfdb:Dumping table gear
#> 2026-01-25 17:20:52.88612 INFO:mfdb:Dumping table vessel_type
#> 2026-01-25 17:20:52.887435 INFO:mfdb:Dumping table vessel_owner
#> 2026-01-25 17:20:52.888592 INFO:mfdb:Dumping table market_category
#> 2026-01-25 17:20:52.889748 INFO:mfdb:Dumping table sex
#> 2026-01-25 17:20:52.891018 INFO:mfdb:Dumping table maturity_stage
#> 2026-01-25 17:20:52.892276 INFO:mfdb:Dumping table species
#> 2026-01-25 17:20:52.896984 INFO:mfdb:Dumping table areacell
#> 2026-01-25 17:20:52.898177 INFO:mfdb:Dumping table stomach_state
#> 2026-01-25 17:20:52.899476 INFO:mfdb:Dumping table digestion_stage
#> 2026-01-25 17:20:52.900739 INFO:mfdb:Dumping table sampling_type
#> 2026-01-25 17:20:52.901908 INFO:mfdb:Dumping table population
#> 2026-01-25 17:20:52.903066 INFO:mfdb:Dumping table data_source
#> 2026-01-25 17:20:52.904217 INFO:mfdb:Dumping table index_type
#> 2026-01-25 17:20:52.905553 INFO:mfdb:Dumping table port
#> 2026-01-25 17:20:52.906753 INFO:mfdb:Dumping table trip
#> 2026-01-25 17:20:52.907962 INFO:mfdb:Dumping table tow
#> 2026-01-25 17:20:52.909205 INFO:mfdb:Dumping table vessel
#> 2026-01-25 17:20:52.910367 INFO:mfdb:Dumping table case_study
#> 2026-01-25 17:20:52.911669 INFO:mfdb:Dumping table survey_index
#> 2026-01-25 17:20:52.912837 INFO:mfdb:Dumping table division
#> 2026-01-25 17:20:52.913982 INFO:mfdb:Dumping table sample
#> 2026-01-25 17:20:52.915253 INFO:mfdb:Dumping table predator
#> 2026-01-25 17:20:52.916492 INFO:mfdb:Dumping table prey
mfdb_cs_restore(mdb_in, dump_path)
#> 2026-01-25 17:20:53.023301 INFO:mfdb:Restoring table institute
#> 2026-01-25 17:20:53.20556 INFO:mfdb:Restoring table bait_type
#> 2026-01-25 17:20:53.207113 INFO:mfdb:Restoring table net_type
#> 2026-01-25 17:20:53.207943 INFO:mfdb:Restoring table gear
#> 2026-01-25 17:20:53.376716 INFO:mfdb:Restoring table vessel_type
#> 2026-01-25 17:20:53.543862 INFO:mfdb:Restoring table vessel_owner
#> 2026-01-25 17:20:53.545231 INFO:mfdb:Restoring table market_category
#> 2026-01-25 17:20:53.546091 INFO:mfdb:Restoring table sex
#> 2026-01-25 17:20:53.716376 INFO:mfdb:Restoring table maturity_stage
#> 2026-01-25 17:20:53.88627 INFO:mfdb:Restoring table species
#> 2026-01-25 17:20:54.061234 INFO:mfdb:Restoring table areacell
#> 2026-01-25 17:20:54.062573 INFO:mfdb:Restoring table stomach_state
#> 2026-01-25 17:20:54.231354 INFO:mfdb:Restoring table digestion_stage
#> 2026-01-25 17:20:54.401386 INFO:mfdb:Restoring table sampling_type
#> 2026-01-25 17:20:54.402707 INFO:mfdb:Restoring table population
#> 2026-01-25 17:20:54.403533 INFO:mfdb:Restoring table data_source
#> 2026-01-25 17:20:54.404281 INFO:mfdb:Restoring table index_type
#> 2026-01-25 17:20:54.571018 INFO:mfdb:Restoring table port
#> 2026-01-25 17:20:54.572437 INFO:mfdb:Restoring table trip
#> 2026-01-25 17:20:54.57334 INFO:mfdb:Restoring table tow
#> 2026-01-25 17:20:54.574294 INFO:mfdb:Restoring table vessel
#> 2026-01-25 17:20:54.57513 INFO:mfdb:Restoring table case_study
#> 2026-01-25 17:20:54.742874 INFO:mfdb:Restoring table survey_index
#> 2026-01-25 17:20:54.744138 INFO:mfdb:Restoring table division
#> 2026-01-25 17:20:54.744928 INFO:mfdb:Restoring table sample
#> 2026-01-25 17:20:54.746103 INFO:mfdb:Restoring table predator
#> 2026-01-25 17:20:54.747094 INFO:mfdb:Restoring table prey

mfdb_disconnect(mdb_in)
mfdb_disconnect(mdb_out)