Maintenance script to backup, update and get server status
- Backup of web server
- Backup of MySQL database
- System's update
- Check for website status
start
sudo sh maintenance.sh start
status
sudo sh maintenance.sh status
stop
sudo sh maintenance.sh stop
-
Debian
mv maintenance.sh maintenance && sudo mv maintenance /etc/init.d/
service maintenance start
-
CentOS
-
create a file called maintenance.service
touch maintenance.service
-
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
-
chmod to 644
chmod 644 maintenance.service
-
move the files
mv maintenance.sh maintenance && sudo mv maintenance /opt/
sudo mv maintenance.service /usr/lib/systemd/system/
-
reboot your system to apply the changes
reboot
-
start the script
systemctl start maintenance
-
install
sudo systemctl enable maintenance