SSH backup website

Well sometimes it is time consuming and very irritating to backup a website using FTP/web interface.

Login using SSH on your website.

Via terminal (apple), putty (windows), use the following commands:
mysql db:  mysqldump -u dbusername databasename -p > outputfile.sql
websites:   zip -9 -r zipfilename.zip [relative folder to path] unzip zipfilename.zip

then download it via your website. FTP goes too slow.

And your done…

 

Restore database:

Create in the destination server a new database, user for the new database, and password for the user to that database. Let us say that the three you created are respectively, database_name, database_user, and database_password.

Download the dump file to the destination server from the origin server. Issue the following command:

wget http://www.example.com/dump.gxx
mv dump.gxx dump.sql

What is the meaning of the code above?
The line wget http://www.example.com/dump.gxx will download the file dump.gxx to the destination server. That is the reason why I work under public_html directory of the origin server so that I can access the file easily. The code mv dump.gxx dump.sql rename the file dump.gxx to dump.sql.

Finally start the import process,
mysql -u database_username -p -D database_name --default_character_set utf8 < dump.sql

It will ask you a password, give the database_password you just created.

NTPD update linux

On RHEL/CentOS you can force ntpd to syncronize on service startup by doing the following:

# vi /etc/sysconfig/ntpd

There is an OPTIONS variable with something like:

OPTIONS=”-u ntp:ntp -p /var/run/ntpd.pid”

Add the -x parameter:

OPTION=”-x -u ntp:ntp -p /var/run/ntpd.pid”

You may also want to set SYNC_HWCLOCK option to “yes”, in order to also syncronize hardware clock.

Then restart the service:

# service ntpd restart

The ntp daemon will be forced to resync every time you restart the service.