Linux web server backup script
Everyone knows that nowadays normally very important to take backups. This is not such a pleasant work and there often comes a long time. If you have a linux web server, you can automate this task very easy. In this tutorial I'll leave a small bash script to see your web files with a backup of your MySQL database into a tar.gz (like a zip) file sets.
Bash backup script
This script is not the best script that there is only work and is very compact. You can do it more as a preview for your own backup script to build.

The script itself is as follows:
0 1 2 3 | #! / bin / bash mysql gebruikersnaam ] -p [ mysql wachtwoord ] [ databasenaam ] > mysql_backup.sql mysql dump-u [mysql username]-p [password mysql] [database name]> mysql_backup.sql ` date + % Y % m % d ` .tar.gz / var / www / html mysql_backup.sql tar-czf `date +% Y% m% d`. tar.gz / var / www / html mysql_backup.sql mysql_backup.sql rm-f mysql_backup.sql |
The first line ensures that the bash shell is used for the script to run. The second line is a sql backup of the database you specify. Note that between p and your password is no space. Then, a tar of the web files and mysql backup. Tar This will be named today's date will be. The folder shows you can change the folder that you want to back up. Finally, the mysql_backup file removed.
Put the script in a file called backup.sh. Give the rights with the following command.
0
| chmod u + x backup.sh |
Now you can run the script with:
0
| . / Backup.sh |
The resulting tar file, you can in a safe place so you always have a backup if something should go wrong.

























Leave your response!