Back up the entire website with SSH Command Line
Backing up an entire website or blog can be a difficult and complicated process, requiring a lot of software, support tools, administrators with many skills and experiences, or direct support. from the hosting provider. But in fact, sometimes you won't need the above elements ...
Backing up an entire website or blog can be a difficult and complicated process, requiring a lot of software, support tools, administrators with many skills and experiences, or support. directly from the hosting provider. But in fact, sometimes you will not need these factors. If you have SSH rights to access the host (minimum requirement is 1 virtual private network model - Virtual Private Server ), then things will become much simpler, you can backup, restore, move transfer . or perform other operations with the entire website with only a few commands.
So what is SSH Command Line?
In other words, SSH allows you to 'talk' directly to the web server. There is no concept of interface, function control buttons . all are done via the basic command line. Maybe this is a huge obstacle for many people, but in return, the absolute power, extremely fast working speed with high flexibility, integration of many automated mechanisms . then SSH Command Line becomes an indispensable tool once you've mastered it.
But in fact, most shared hosting packages do not provide SSH access to the user's account. If you are using GoDaddy's service, please refer to this process here. To login via SSH, open the Terminal application in OS X and type the following command:
ssh username@yourdomain.com
The system will ask the user to enter the password, if you have never used SSH before, it will be surprising that when you type the password, the screen does not display anything. No need to worry, because that feature is used to ensure system safety. After logging in, all you see is just the command line, similar to the following:
-bash-$ 3.2
It means that everything is stable. Next, we will learn more about other basic syntaxes. To list the current directory and file list, type the command:
ls
If you want to change the directory:
cd directoryname
In this case, we will move to the httpdocs directory - the root of the entire website, using the following command:
Backup database:
In fact, this can be considered as a process of backing up all the important files of the website. The first is the 3 most important information of the entire database, found in the wp-config.php file (for WordPress):
- Database name
- Database account
- Password
When using this command syntax, remember to replace the above information with the actual system, including the username, table name, backup file . respectively:
mysqldump --add-drop-table -u username -p tablename> backupfilename.sql
Press Enter, enter the password and the process will automatically proceed. Remember to use the ls command to check if the generated files are correct with the request.
Data backup:
After the above step, the entire database has been backed up into a single sql file on the server, followed by the process of backing up all data into a single compressed file, in case the risk occurs.
tar -vcf yourbackupfilename.tar.
Replace yourbackupfilename with the backup file name according to your wishes. At this command, Tar is a popular compression file format in Linux, similar to zip but much more efficient, and -vcf is another system option, with the function of creating compressed files and listing lists. The book is in progress, followed by the name of the archive. Finally, a dot to ask the system to back up everything, we can use * instead, but sometimes ignore hidden files like .htaccess - which is very important to WordPress.
After finishing the process, we will have a single .tar archive file, all you need to do at this time is to log in via FTP and download the file to your computer.
Restore everything:
Assuming that the worst case scenario occurs, you lose all of the website's data, all that remains is the backup file of the above process. And now the thing to do right now is restore the website's activity. First, log in via FTP and upload the backup file to the server, and remember to move the most recent backup file out of the root directory and proceed with it.
Extract the backup file directly on the server:
tar -vxf yourbackupfilename.tar
The difference here compared to the above statement is the -vxf syntax, which means extracting that * .tar file. The important point to note is that in this step, create a completely empty database with the same account name and password as the previous database, then type the command:
mysql -u username -p tablename> databasebackupfilename.sql
Very simple and easy, if everything is set up according to the requirements of the system, the backup process will be completed quickly and you will no longer have to struggle as before. In the next lesson, we will learn and implement this process automation with the shell script and CRON statements. Good luck!
You should read it
- What is Admin? Admin Facebook, what is the website?
- 4 ways to manage the process of Backup Windows Server 2008 on multiple servers
- Instructions for managing programs in Ubuntu via the command line
- What to back up on a Linux Home Server system?
- Adjust admin section of WordPress
- How to recover the content entered on the website
- What is technical SEO?
- How to assign admin rights to users in Ubuntu
- Install WordPress directly on the CPanel website
- Command line parameter in C
- Save messages from iPhone to CVS file on Mac OS X
- 10 commands Windows 7 network administrators need to know
Maybe you are interested
Rare volcano spits out real gold Indonesian volcano erupted, creating a column of smoke as high as nearly 200 meters 12 myths in Hollywood movies that viewers believe in How to sign up for Gmail, create and create a Google account How to sign in to Gmail, sign in to multiple Gmail accounts at the same time How to delete all emails of a specific sender on Gmail?