/maintenance

Maintenance script to backup, update and get server status

Primary LanguageShellGNU General Public License v2.0GPL-2.0

Maintenance

Maintenance script to backup, update and get server status

This script does the folliwing actions
  • Backup of web server
  • Backup of MySQL database
  • System's update
  • Check for website status

Usage

start
sudo sh maintenance.sh start

status
sudo sh maintenance.sh status

stop
sudo sh maintenance.sh stop

If you prefer, you can turn it into a service
  • Debian
    mv maintenance.sh maintenance && sudo mv maintenance /etc/init.d/
    service maintenance start

  • CentOS

  1. create a file called maintenance.service
    touch maintenance.service

  2. edit the file as below
    vim maintenance.service

[Unit]
Description=Maintenance script to backup, update system and retrieve website status

[Service]
Type=simple
ExecStart=/bin/bash /opt/maintenance start
ExecReload=/bin/bash /opt/maintenance reload
ExecStop=/bin/bash /opt/maintenance stop
PIDFile=/var/run/maintenance.pid

[Install]
WantedBy=multi-user.target
  1. chmod to 644
    chmod 644 maintenance.service

  2. move the files
    mv maintenance.sh maintenance && sudo mv maintenance /opt/
    sudo mv maintenance.service /usr/lib/systemd/system/

  3. reboot your system to apply the changes
    reboot

  4. start the script
    systemctl start maintenance

  5. install
    sudo systemctl enable maintenance