Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

RestoreBackupSh

Oliver Salzburg edited this page Mar 14, 2013 · 4 revisions

Introduction

The main purpose of restoreBackup.sh is to restore snapshots previously created by createBackup.sh. It is unlikely to have any use as a stand-alone script.

Privileges

Due to the fact that restoreBackup.sh tries to delete the TYPO3 base installation folder, elevated privileges (sudo) might be required. This is required because TYPO3 most likely created files in the installation folder that are now owned by the user that runs the HTTP daemon. See the following example output illustrating the issue noted above.

/var/www/t3site$ ./restoreBackup.sh typo3-2012-01-02-17-56.tgz
Sourcing script configuration from restoreBackup.conf...Done.
Testing write permissions in typo3...Failed!
typo3/typo3conf/temp_CACHED_pse643_ext_localconf.php is not writable!

To work around this issue, you could rename the TYPO3 base installation directory and re-create it.

/var/www/t3site$ mv typo3 backup
/var/www/t3site$ mkdir typo3
/var/www/t3site$ ./restoreBackup.sh typo3-2012-01-02-17-56.tgz
Sourcing script configuration from restoreBackup.conf...Done.
Testing write permissions in typo3...Succeeded
Erasing current TYPO3 installation 'typo3'...Done.
Extracting TYPO3 backup 'typo3-2012-01-02-17-56.tgz'...Done.
Importing database dump...Done.
Deleting database dump...Done!

Arguments

$ ./restoreBackup.sh --help
  Usage: ./restoreBackup.sh [OPTIONS] [--file=]<FILE>

  Core:
  --help              Display this help and exit.
  --verbose           Display more detailed messages.
  --quiet             Do not display anything.
  --force             Perform actions that would otherwise abort the script.
  --update            Tries to update the script to the latest version.
  --update-check      Checks if a newer version of the script is available.
  --export-config     Prints the default configuration of this script.
  --extract-config    Extracts configuration parameters from TYPO3.
  --base=PATH         The name of the base path where TYPO3 is
                      installed. If no base is supplied, "typo3" is used.

  Options:
  --file=FILE         The file in which the backup is stored.

  Database:
  --hostname=HOST     The name of the host where the TYPO3 database is running.
  --username=USER     The user name to use when connecting to the TYPO3
                      database.
  --password=PASSWORD The password to use when connecting to the TYPO3
                      database.
  --database=DB       The name of the database in which TYPO3 is stored.

Overview

For general information regarding the configuration of scripts in the typo3scripts suite, please see the article about Configuration.

Hint: It may be desirable to share a configuration file (at least) between createBackup.sh and restoreBackup.sh.

Command Line Parameters

  • --help

    Prints the output seen above, giving an overview of available command line parameters.

  • --verbose

    Enable verbose (more detailed) output.

  • --quiet

    Reduced verbosity (less detailed) output.

  • --force

    Perform actions that would otherwise stop execution.

  • --update

    Invokes the self-updating mechanism in this script. This will download the latest release version from the official source code repository and replace your current script.

    Note: To perform a quick check if a new version is available, run restoreBackup.sh with the --update-check parameter. If a new version is found online, the following message will be printed to the standard output:

    NOTE: New version available!
    

    In previous versions, this check would be performed every time you run the script.

  • --export-config

    Print the default configuration of the script to the standard output.

    This allows for easy generation of a default config file, like so:

      $ ./restoreBackup.sh --export-config > typo3scripts.conf
    
  • --extract-config

    Tries to read the database-related parameters out of the TYPO3 configuration file.

    This allows for easy generation of a base config file for other typo3scripts after you have completed your TYPO3 installation.

      $ ./restoreBackup.sh --extract-config > typo3scripts.conf
    

    In case you're using a non-default TYPO3 installation directory, make sure to supply the --base parameter before the --extract-config parameter.

      $ ./restoreBackup.sh --base=myt3site --extract-config > typo3scripts.conf
    

    Note: This functionality is currently not compatible with TYPO3 6.0 configuration file format.

  • --base / BASE

    By default, it is assumed that the TYPO3 installation is located in a sub-folder relative to the current working directory, named typo3. Use --base if the installation is placed in a differently named sub-folder.

      $ ./restoreBackup.sh --file=typo3-2012-01-02-17-56.tgz --base=myt3site
    
  • --file / FILE

    The name of the snapshot file that should be restored.

      $ ./restoreBackup.sh --file=typo3-2012-01-02-17-56.tgz
    
  • --hostname / HOST

    The name of the host where the database for TYPO3 is running.

  • --username / USER

    The user name for the connection to the database for the TYPO3 installation.

  • --password / PASS

    The password for the connection to the database for the TYPO3 installation.

  • --database / DB

    The name of the database for the TYPO3 installation.

Examples

Installation

/var/www$ cd t3site/
/var/www/t3site$ wget https://raw.github.com/oliversalzburg/typo3scripts/master/restoreBackup.sh
/var/www/t3site$ chmod 700 restoreBackup.sh

Restoring a snapshot

/var/www/t3site$ sudo ./restoreBackup.sh typo3-2012-02-12-18-35.tgz
Sourcing script configuration from typo3scripts.conf...Done.
Checking dependencies...Succeeded.
Testing write permissions in typo3...Succeeded
Erasing current TYPO3 installation 'typo3'...Done.
Extracting TYPO3 backup 'typo3-2012-02-12-18-35.tgz'...Done.
Importing database dump...Done.
Deleting database dump...Done!

This example assumes that you previously created a configuration file typo3scripts.conf to share between scripts. Please see the article about Configuration for more information.