J4.x

CLI Database Exporter Importer: Difference between revisions

From Joomla! Documentation

mNo edit summary
Marked this version for translation
Line 3: Line 3:
{{-}}
{{-}}
<translate>
<translate>
== About ==
== About == <!--T:1-->
</translate>
</translate>
<translate>Before updating Joomla! or [[S:MyLanguage/J4.x:CLI Update|installing a third party extension]], it is strongly recommended that you back up your site.<br />
<translate><!--T:2-->
Before updating Joomla! or [[S:MyLanguage/J4.x:CLI Update|installing a third party extension]], it is strongly recommended that you back up your site.<br />
The Joomla! 4.x Console provides commands for exporting (backing up) and importing (restoring) your Joomla! database.</translate>
The Joomla! 4.x Console provides commands for exporting (backing up) and importing (restoring) your Joomla! database.</translate>


<translate>
<translate>
== Requirements ==
== Requirements == <!--T:3-->
</translate>
</translate>
<translate>To use these commands, you need a secured shell access (SSH) to your host on which the PHP CLI (Command Line Interface) is installed.
<translate><!--T:4-->
To use these commands, you need a secured shell access (SSH) to your host on which the PHP CLI (Command Line Interface) is installed.
Consider to have basic knowledge of using shell commands.</translate>
Consider to have basic knowledge of using shell commands.</translate>


<translate>
<translate>
== Instructions ==
== Instructions == <!--T:5-->
</translate>
</translate>
<translate>Log in to your host and go to the root folder of your site.<br />
<translate><!--T:6-->
Log in to your host and go to the root folder of your site.<br />
I recommend to use the Joomla 'tmp' folder in your <folder_path> to have read/write permissions.</translate>
I recommend to use the Joomla 'tmp' folder in your <folder_path> to have read/write permissions.</translate>


* <translate>List all available commands of the Joomla Console:<br /><tt>php cli/joomla.php list</tt></translate>
* <translate><!--T:7--> List all available commands of the Joomla Console:<br /><tt>php cli/joomla.php list</tt></translate>
* <translate>Export the database to the folder:<br /><tt>php cli/joomla.php database:export --all --folder <folder_path></tt></translate>
* <translate><!--T:8--> Export the database to the folder:<br /><tt>php cli/joomla.php database:export --all --folder <folder_path></tt></translate>
* <translate>Import the database from folder:<br /><tt>php cli/joomla.php database:import --all --folder <folder_path></tt></translate>
* <translate><!--T:9--> Import the database from folder:<br /><tt>php cli/joomla.php database:import --all --folder <folder_path></tt></translate>


<translate>You can also:</translate>
<translate><!--T:10--> You can also:</translate>
<translate>* Export the database in a zip file:<br /><tt>php cli/joomla.php database:export --all --zip</tt>
<translate><!--T:11-->
* Export the database in a zip file:<br /><tt>php cli/joomla.php database:export --all --zip</tt>
* Export a table:<br /><tt>php cli/joomla.php database:export --table <table_name></tt>
* Export a table:<br /><tt>php cli/joomla.php database:export --table <table_name></tt>
* Export a table as a .zip file:<br /><tt>php cli/joomla.php database:export --table <table_name> --zip</tt>
* Export a table as a .zip file:<br /><tt>php cli/joomla.php database:export --table <table_name> --zip</tt>
Line 32: Line 36:


<translate>
<translate>
== Back up and restore ==
== Back up and restore == <!--T:12-->
</translate>
</translate>
<translate>To make a full backup (with folders, files and database) of your site, you can execute these commands:</translate>
<translate><!--T:13--> To make a full backup (with folders, files and database) of your site, you can execute these commands:</translate>
<translate>
<translate>
<!--T:14-->
# Archive your Joomla root directory:<br /><tt>tar --exclude='./tmp/joomla_bak.*' -zcvf tmp/joomla_bak.tgz . > tmp/joomla_bak.log</tt>
# Archive your Joomla root directory:<br /><tt>tar --exclude='./tmp/joomla_bak.*' -zcvf tmp/joomla_bak.tgz . > tmp/joomla_bak.log</tt>
# Export all the Joomla database:<br /><tt>php cli/joomla.php database:export --all --folder tmp/db_bak</tt></translate>
# Export all the Joomla database:<br /><tt>php cli/joomla.php database:export --all --folder tmp/db_bak</tt></translate>


<translate>And to restore it, execute these commands:</translate>
<translate><!--T:15--> And to restore it, execute these commands:</translate>
<translate># Import all the Joomla database:<br /><tt>php cli/joomla.php database:import --all --folder tmp/db_bak</tt>
<translate><!--T:16-->
# Import all the Joomla database:<br /><tt>php cli/joomla.php database:import --all --folder tmp/db_bak</tt>
# Extract the archive:<br /><tt>tar --recursive-unlink -xvf tmp/joomla_bak.tgz .</tt></translate>
# Extract the archive:<br /><tt>tar --recursive-unlink -xvf tmp/joomla_bak.tgz .</tt></translate>



Revision as of 22:55, 27 May 2019

Joomla! 
4.0

About

Before updating Joomla! or installing a third party extension, it is strongly recommended that you back up your site.
The Joomla! 4.x Console provides commands for exporting (backing up) and importing (restoring) your Joomla! database.

Requirements

To use these commands, you need a secured shell access (SSH) to your host on which the PHP CLI (Command Line Interface) is installed. Consider to have basic knowledge of using shell commands.

Instructions

Log in to your host and go to the root folder of your site.
I recommend to use the Joomla 'tmp' folder in your <folder_path> to have read/write permissions.

  • List all available commands of the Joomla Console:
    php cli/joomla.php list
  • Export the database to the folder:
    php cli/joomla.php database:export --all --folder <folder_path>
  • Import the database from folder:
    php cli/joomla.php database:import --all --folder <folder_path>

You can also:

  • Export the database in a zip file:
    php cli/joomla.php database:export --all --zip
  • Export a table:
    php cli/joomla.php database:export --table <table_name>
  • Export a table as a .zip file:
    php cli/joomla.php database:export --table <table_name> --zip
  • Import a table:
    php cli/joomla.php database:import --table <table_name>
  • If you need help:
    php cli/joomla.php database:export --help php cli/joomla.php database:import --help

Back up and restore

To make a full backup (with folders, files and database) of your site, you can execute these commands:

  1. Archive your Joomla root directory:
    tar --exclude='./tmp/joomla_bak.*' -zcvf tmp/joomla_bak.tgz . > tmp/joomla_bak.log
  2. Export all the Joomla database:
    php cli/joomla.php database:export --all --folder tmp/db_bak

And to restore it, execute these commands:

  1. Import all the Joomla database:
    php cli/joomla.php database:import --all --folder tmp/db_bak
  2. Extract the archive:
    tar --recursive-unlink -xvf tmp/joomla_bak.tgz .