Follow

How to Backup, Restore, Export and Import SDElements Data (database backup)

Note: The following instructions are prepared for SD Elements versions 3.0 or above. On older versions, you need to replace the following string:

sde manage_django

with

/docs/sde/live/env/bin/python /docs/sde/live/code/sigma/manage.py

for all the commands.

A. Backup: Exporting all data from an existing SDElements server for backup and/or other purposes

  1. Log into the SDElements server using SSH, this can be done using the Putty SSH client or the SSH client of your choice.
  2. Get the DB password from the file: /docs/sde/live/code/sigma/local_settings.py (Note: In new deploys, you might need to be sde_admin or root to read the file)
  3. Find the DB name, usually sde_x_y_z which x.y.z is the version. For example, sde_2_31_13 for 2.31.13 standard installation or docs_sde_2_31_13sei for custom installations.

    [Optional] You can run the following to list the available databases:
    psql -h localhost -U [sde_user] -W -l
  4. Run the following:
    pg_dump -h localhost -U [sde_user] -W [database_name] > backup.sql 

B. Restore: Importing data from a backed up export file to restore

DISCLAIMER: Use this only to restore data onto the same server the backup was made from.

  1. Log into the SDElements server using SSH, this can be done using the Putty SSH client or the SSH client of your choice.
  2. Transfer and existing SDElements export file to the server
  3. Get the DB password from the file: /docs/sde/live/code/sigma/local_settings.py
  4. Find the DB name, usually sde_x_y_z which x.y.z is the version. For example, sde_2_31_13 for 2.31.13 standard installation or docs_sde_2_31_13sei for custom installations.

    [Optional] You can run the following to list the available databases:
    psql -h localhost -U sde_user -W -l
  5. Get a backup of the database you want to restore. e.g. using this command:
    pg_dump -h localhost -U [sde_user] -W [database_name] > old_backup.sql
  6. Run the following commands:
    dropdb -h localhost -U [sde_user] -W [database_name]
    createdb -h localhost -U [sde_user] -W [database_name]
    psql -h localhost -U [sde_user] -W[database_name] < backup.sql

C. Moving Data (same version): Importing data backed up from one SD Elements server to another SD Elements server on same version

DISCLAIMER: This will move and overwrite all of the data including in-app settings. However, it will not retain the uploaded files, such as logos for theming, SAML metadata files, SSL Certificates, SAML Certificates, and other configurations. Those need to be moved manually.

  1. Ensure that the target server is running the same version as source.
  2. Backup from the source server using the backup instructions above (section A).
  3. Copy the contents of /docs/sde/keyczar/ from source server, make sure permissions are preserved.
  4. Restore to the target server using the restore instructions above (section B).
  5. Backup the contents of /docs/sde/keyczar/ on the target server. You will need these if you decide to roll back or use the original data.
  6. Copy the content of the saved keyczar file onto the target server.
  7. Restart celery and apache service:
    sudo service apache2 restart || sudo service httpd restart
    sudo service celeryd restart || sudo supervisorctl restart all

D. Moving Data (to newer version): Moving data from an older SD Elements server to a newer SD Elements server

DISCLAIMER: This will move all of the data including in-app settings. However, it will not retain the uploaded files, such as logos for theming, SAML metadata files, SSL Certificates, SAML Certificates, and other configurations. Those need to be moved manually.

  1. Save the built-in content from the new server (to be applied later):
    /docs/sde/live/env/bin/python /docs/sde/live/code/sigma/manage.py dump-builtin-data > /tmp/content.json

    Alternatively, you can try this:
    tar -xzf /docs/sde/deployable-releases/sde-3.0.45-full.tgz -C /tmp '*/bundle.tar'
    tar -xf /tmp/3.0.45/bundle.tar -C /tmp './content.json'
  2. Run through steps 2 through 6 moving data between same versions (Section C, steps C.2 to C.6 inclusive)
  3. Run the following commands:
    sde manage_django fake_migrations
    sde manage_django migrate --noinput
    sde manage_django disable-builtin-data

    sde manage_django loaddata /tmp/content.json

    sde manage_django post-deploy
    sde manage_django update_index --age=720

    Note: It is important to see 1 fixture loading when running loaddata (see below). It won't give you an error if it can't read the file. Instead, it will import 0 fixtures, which means that it failed.
    -bash-4.1$ sde manage_django loaddata /tmp/content.json
    Installed 6462 object(s) from 1 fixture(s)
  4. Restart celery and apache service:
    sudo service apache2 restart || sudo service httpd restart
    sudo service celeryd restart || sudo supervisorctl restart all
Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Antonia Stevens

    Please note that if you are copying the database to another server then you will need to copy keyczar keys with the database and make sure all permissons are correct. This includes selinux permissions if running on a RedHat based platform.