Giter Site home page Giter Site logo

muhmah-motahari / website-backup-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smithalan2/website-backup-script

0.0 0.0 0.0 6 KB

This a a Linux bash script for backing up the files and database for a website to a local server.

License: MIT License

Shell 100.00%

website-backup-script's Introduction

Website Backup Script


##Summary This a a Linux bash script for backing up the files and mysql database for a website to the server. It creates a zip file with a MySQL DB dump and zip of all the files.


##Usage To use this script, Login to your server via SSH. CD to a folder on your server to store the backup script. If GIT is not already installed on your server run the following command.

####Note - Ensure the line endings of the backup.sh file are set to Unix, not DOS.

Debian

sudo apt-get install git-core

Ubuntu

sudo apt-get install git

Once git is installed clone this repository using the following command

git clone https://github.com/smithalan2/website-backup-script.git

This will clone the repository into a new folder called website-backup-script, Inside this folder there is the backup.sh script. Make the changes outlined in the configuration section on this page. You can then run the script by cding ito the website-backup-script directory and executing the following command

bash backup.sh

The script will output what it is doing when executing and notify you of the path to the saved backup file.

To set up the script to run automatically, you can simply place the shell script in one of the following folders /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly. Otherwise you can use crontab to schedule it yourself. Issue the following command in the terminal

crontab -e

It may prompt you to choose an editor, I generally prefer nano. You can then add a line to the bottom of this file in the following format

minute hour day-of-month month day-of-week /path/to/shell/script

Eg. 0 5 * * 6 /var/home/user/backup.sh This will execute the script at 05:05 every Saturday.


##Configuration A number of values need to be specified for the script to work. They are as listed below

###MySQL User You should replace db_user with the database user with permission to access the database you wish to backup.

mysql_user="db_user"

###MySQL Password You should replace db_pass with the password for the user mentioned above

mysql_pass="db_pass"

###MySQL Host If needed you should change localhost to your database server. Generally you can keep it as localhost.

mysql_host="localhost"

###MySQL Database This is the database you want to backup. Replace db_name with the name of the database.

mysql_db="db_name"

###File Directory This is the directory containing any subfolders and files belonging to the website you wish to backup. Generally this is something along the lines of /var/www/html

file_dir="/var/www/html/mysite"

###Backup Folder This is the directory where you wish to store the backups that are generated. Ideally this should be a directory that is not accessible via http. Do not include a trailing slash. This directory needs to be created before running this script.

backupfolder="/var/home/user/backups"

website-backup-script's People

Contributors

smithalan92 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.