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.

QR Code
0 antwoorden

Plaats een Reactie

Draag gerust bij!

Geef een antwoord

Het e-mailadres wordt niet gepubliceerd.

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.