Restoring database ( Integrated Code Editor )

In this article you will learn how to restore database backup using instance's integrated code editor, it is important in cases you want to restore huge database backups

Basic Authentication

Use below script if you are using username and password to access your server


# BACKUP_PATH is the path to your backup zip file
BACKUP_PATH=REPLACE_WITH_BACKUP_FILE_PATH

# USERNAME is the username to access your server using private key
USERNAME=REPLCE_WITH_USERNAME  

# SERVER_IP is the ip address of the server hosting your instance
SERVER_IP=REPLACE_WITH_SERVER_IP

# INSTANCE_UUID is the unique identifier of the instance you want to upload backup to
INSTANCE_UUID=REPLACE_WITH_INSTANCE_UUID 

# This command will set proper permission, connect and upload backup file to the appropriate path (Copy as is)
scp "$BACKUP_PATH" "$USERNAME@$SERVER_IP:/var/backups/$INSTANCE_UUID/"

You will be prompted to enter password for the username you provided

Private Key Authentication

Use below script if you are using private key to access your server


# KEY_PATH is the path to your private key file
KEY_PATH=REPLACE_WITH_PRIVATE_KEY_PATH 

# BACKUP_PATH is the path to your backup zip file
BACKUP_PATH=REPLACE_WITH_BACKUP_FILE_PATH

# USERNAME is the username to access your server using private key
USERNAME=REPLCE_WITH_USERNAME  

# SERVER_IP is the ip address of the server hosting your instance
SERVER_IP=REPLACE_WITH_SERVER_IP

# INSTANCE_UUID is the unique identifier of the instance you want to upload backup to
INSTANCE_UUID=REPLACE_WITH_INSTANCE_UUID 

# This command will set proper permission, connect and upload backup file to the appropriate path (Copy as is)
chmod 600 "$KEY_PATH" && scp -i "$KEY_PATH" "$BACKUP_PATH" "$USERNAME@$SERVER_IP:/var/backups/$INSTANCE_UUID/"

Restoration 

Open your instance code editor from Project Console > Select Instance > Access Information Tab 

You will be redirected to the instance code editor, open terminal by clicking menu > Terminal > New Terminal

In terminal copy and paste below command 

odoobot_restore $DATABASE_NAME /var/backups/backup.zip yes