Support > FAQs

Full Elxis backup and restore

(1/3) > >>

datahell:
This guide will show you show you can easily backup/restore an Elxis site. This guide is for server administrators and requires that you have a root account on the server. Notice: Shell scripts using  cron/jobs are also available (contact GO UP Inc for this) if you wish to create a demo site that will be refreshed automatically.

BACKUP
--> Database
Nothing special. Login to PHPmyAdmin and take a full backup. Check these options:
Add drop table
use backticks (`)
add auto increment

export as .sql file
Ok, you now have the database backup.

--> Files
Let's say the absolute path to our Elxis site is:
/home/user/public_html

Login into shell. Go to the Elxis root directory:

cd /home/user/public_html

tar everything:
tar -cf /home/user/sitebackup.tar .

Finish. Our files backup is at /home/user/sitebackup.tar


RESTORE
Take the sql file (ix sqlbackup.sql) previously created and place it inside /home/user directory.

We will create a small shell script (elxisrestore.sh) and then we will execute it at once.
To create it simple touch it:
cd /home/user
touch elxisrestore.sh

Then open it to edit it.
nano -w elxisrestore.sh

Add inside it the following code:


--- Code: (shell) ---#!/bin/bash
#
# elxisrestore.sh v1.0 by Ioannis Sannos (Elxis Team)
#

# Parameters
elxisrootdir="/home/user/public_html"
tarfile="sitebackup.tar"
sqlfile="sqlbackup.sql"
startdir="/home/user"

# Database connection information
dbname="my_database_name"
dbhost="localhost"
dbuser="database_user"
dbpw="database_password"

# Remove old website files
rm -rf $elxisrootdir/*

# UnTAR Elxis files
cd $elxisrootdir
tar xf $startdir/$tarfile

cd $startdir
echo "use $dbname; set names utf8; source $sqlfile;" | mysql --password=$dbpw --user=$dbuser --host=$dbhost
--- End code ---

Notice the "set names utf8;" command that we added after database selection.

Save this file as elxisrestore.sh
To get out of the editor press Ctrl+X. And then y (yes)

Go to /home/user directory:
cd /home/user

Change permissions to 777to the shell script  inorder to be executable:
chmod 777 elxisrestore.sh

finally execute it:

. elxisrestore.sh

That will restore both your files and database.

Hope you liked it!

Farhad Sakhaei:
hi john , i want to use Shell scripts using  cron/jobs to create a demo site , what do i to do?

datahell:
What exactly do you want to do? Create a demo site? Automatic backup? Something else? Better contact me via e-mail.

Farhad Sakhaei:
i sent you a pm

ahmet:
what happens if we dont have access to  shell ???
cant we restore the site from ftp and php my admin?
if theres can you tell me..
thanks..

Navigation

[0] Message Index

[#] Next page

Go to full version