> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Restoring a backup

> This page provides instructions for restore of FlexDeploy from previous backup, perhaps to undo an upgrade. If you are using automated installer, then

This page provides instructions for restore of FlexDeploy from previous backup, perhaps to undo an upgrade.

If you are using automated installer, then backups for folders and files is located at \$FLEXDEPLOY\_HOME/upgrade/upgrade\_backups/\<MMDDYYYY>/. There would be tomcat, artifacts, plugins sub-folders here.

***

**Step 1**. Stop the FlexDeploy server. Use **StopFlexDeploy.sh** on Linux and **StopFlexDeploy.bat** on Windows. This will stop Tomcat and InfluxDB.

***

**Step 2**. Restore FlexDeploy schemas, Artifact Repository, Plugins directory and apache-tomcat-flexdeploy folder.

First drop schemas (sqlplus, SQL Developer, or other database tools) and then import from backup.

### Drop Schemas

```
drop user fd cascade;
drop user ff cascade;
drop user fd_admin cascade;
```

### Import data from backup directory (PostgreSQL) - If you used the automated installer and specified a backup directory, or you used pg\_dump

```
if you used pg_dump (what the automated installer uses when you specify the backup directory in your config file)
pg_restore --host ${HOST} --port ${PORT} --schema FD --username postgres --verbose --format d --file ${PATH/TO/BACKUP}/FD flexdeploy
pg_restore --host ${HOST} --port ${PORT} --schema FF --username postgres --verbose --format d --file ${PATH/TO/BACKUP}/FF flexdeploy
pg_restore --host ${HOST} --port ${PORT} --schema FD_ADMIN --username postgres --verbose --format d --file ${PATH/TO/BACKUP}/FD_ADMIN flexdeploy
```

### Import data from backup schema (PostgreSQL) - If you used the automated installed and omitted backup directory

```
sudo su - postgres
psql --host ${HOST} --port ${PORT} -d flexdeploy 

alter schema FD_bak rename to FD
alter schema FF_bak rename to FF
alter schema FD_ADMIN_bak rename to FD_ADMIN
```

### Import data (PostgreSQL) from pg\_dumpall

```
psql -U postgres --host ${HOST} --port ${PORT} < fd_db_bkp.bkp

#or if it was gz compressed dumpall,
gunzip -c fd_db_bkp.bkp.gz | psql -U postgres --host ${HOST} --port ${PORT}
```

### Import data from backup (Oracle)

```
# You will need to setup environment variables before running expdp. For example,
 
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=fd01
 
impdp system directory=DATA_PUMP_DIR dumpfile=fd_bkup.dmp schemas=FD,FF,FD_ADMIN
```

### Restore Artifact Repository

Now restore artifact repository. The location of the artifact repository can be identified by looking at value of **-Dflexagon.fd.repository.root** in **setenvoverride.sh**/setenv.sh or **setenvoverride.bat**/setenv.bat file.

```
cd <artifact repository location>
rm -rf *
tar -xvzf <path to artifacts backup>/artifacts.tar.gz
```

### Restore Plugins Directory

Now restore plugins folder. The location of the plugins folder can be identified by looking at value of **-Dflexagon.fd.install.root** in **setenvoverride.sh**/setenv.sh or **setenvoverride.bat**/setenv.bat file. plugins folder is sub-folder for this install root (aka server working directory).

```
cd <server working directory>
cd plugins
rm -rf *
tar -xvzf <path to plugins backup>/plugins.tar.gz
```

### Restore apache-tomcat-flexdeploy Directory

Restore tomcat folder from backup.

```
# Assuming FLEXDEPLOY_HOME environment variable is set, it should be parent folder of apache-tomcat-flexdeploy
export FLEXDEPLOY_HOME=/u01/flexdeploy
cd $FLEXDEPLOY_HOME
mv apache-tomcat-flexdeploy/ apache-tomcat-flexdeploy-before-restore/
mv <path to tomcat backup/apache-tomcat-flexdeploy/ apache-tomcat-flexdeploy/
```

***

**Step 3** . Start FlexDeploy by running the following script

**FLEXDEPLOY\_HOME/apache-tomcat-flexdeploy/bin/StartFlexDeploy.sh** (StartFlexDeploy.bat on Windows)

***
