Skip to content

Exporting and Importing Data Pro Feature

Boxes comes with a powerful command line interface that allows you to export and import data.

An export consists of a couple of YAML files that contain all Box Pages, the Boxes on that page as well as all file attachments from any of these entites.

This allows you to export your whole website structure to the filesystem, back it up or track changes in a version control system.

It also makes it easy to export the website structure for a pull request review, merge it with another branch and then import the merged data again.

Exporting data

To export data, you can use the boxes:export artisan command.

bash
php artisan boxes:export

Export Type

Boxes supports two different export types: full and partial.

A full export exports all Box Pages while a partial export allows you to select which top-level pages you want to export.

A full export is created by default. Use the --partial flag to run a partial export.

bash
php artisan boxes:export --partial

Custom target directory

By default, Boxes exports data to the default directory /themes/<active-theme>/boxes. If you want to use a different target, you can use the --target-dir option.

bash
php artisan boxes:export --target-dir=/tmp/export

Tags

Tags allow you to separate different exports into different folders. This comes in handy when you want to keep multiple exports around.

Use the --tag argument to specify the export tag.

bash
# Exports to /themes/<active-theme>/boxes/new-about-us-section
php artisan boxes:export --partial --tag=new-about-us-section

Attachments

Attachments are exported by default. If you only want to export the page structure but no attachments, use the --no-attachments option.

bash
php artisan boxes:export --no-attachments

Non-interactive mode

You can provide all options on the command line to skip the interactive questions from the export command.

This is useful if you want to run an export via a cronjob or a script.

bash
# Full export to a custom directory.
php artisan boxes:export --target-dir=/tmp/export
# Partial export to the default theme directory.
php artisan boxes:export --partial --pages=1,2,3

Importing data

To import data, you can use the boxes:import artisan command.

bash
php artisan boxes:import

Possible data loss ahead!

Always back up your database and filesystem before running an import!

Read the following table carefully, so you understand how the import system works.

Export TypeImport Mode
FullIf the source is a full export, all pages currently in the database, that are no longer present in this source export, will be deleted.
PartialIf the source is a partial export, no pages will be deleted. New pages are created and existing ones are updated.

Attachments

Attachments are imported by default. If you only want to import the page structure but no attachments, use the --no-attachments option.

bash
php artisan boxes:import --no-attachments

Custom source directory

By default, Boxes imports data from the default directory /themes/<active-theme>/boxes. If you want to use a different source, you can use the --source-dir option.

bash
php artisan boxes:import --source-dir=/tmp/export

Tags

Use the --tag argument to specify the import tag.

bash
# Import from /themes/<active-theme>/boxes/new-about-us-section
php artisan boxes:import --tag=new-about-us-section