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 [relative folder to path] unzip

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:

mv dump.gxx dump.sql

What is the meaning of the code above?
The line wget 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/”

Add the -x parameter:

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

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.