- NO LONGER MAINTAINED!
- These scripts will copy/ move CyberPanel backup archive(s) from
/home/domain/backupdirectory to a specified directory by the user.
- Findutils | Link
-
There are two scripts to work with. One is cpbac_a.sh another one is cpbac_m.sh. If you want to use it with crontab/ systemd timer then cpbac_a.sh is suitable for you. If you want to use it manually with prompt (running it by yourself) then cpbac_m.sh is suitable for you.
-
If you want to use cpbac_a.sh then put the
cpbac_a.shfile to anyhwere you like. E.g.,/home/scripts.
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_a.shpressEnter. - For executing the script, type/ copy
/location/cpbac_a.shpressEnter. - REMEMBER! cpbac_a.sh is suitable for crontab/ systemd timer!.
For crontab:
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_a.shpressEnter. - Open crontab, type/ copy
crontab -epressEnter. - If you want to run the job every day at 12AM, type/ copy
0 0 * * * /location/cpbac_a.sh. - If you want to run the job every day at 12PM, type/ copy
0 12 * * * /location/cpbac_a.sh. - If you want more time flexibility then goto this link.
- After setting cron press
Escand typewqthen pressEnter. - Setting up cron is completed!
For systemd timer:
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_a.shpressEnter. - Create a systemd service unit, type/ copy
/etc/systemd/system/cpbac_a.servicepressEnter. - Copy all of the content from
cpbac_a.servicedown below. - After setting service unit press
Escand typewqthen pressEnter. - Create a systemd timer unit at the same location of service unit, type/ copy
/etc/systemd/system/cpbac_a.timerpressEnter. - Copy all of the content from
cpbac_a.timerdown below. - If you want to run the timer unit every day at 12AM, edit/ copy
*-*-* 00:00:00(This is given on thecpbac_a.timerfile). - If you want to run the timer unit every day at 12PM, edit/ copy
*-*-* 12:00:00. - If you want more time flexibility then goto this link.
- After setting timer unit press
Escand typewqthen pressEnter. - Reload systemd, type/ copy
sudo systemctl daemon-reload. - Enable timer unit, type/ copy
sudo systemctl enable cpbac_a.timer. - Start timer unit, type/ copy
sudo systemctl start cpbac_a.timer. - Setting up systemd timer is completed!
- If you want to use cpbac_m.sh then put the
cpbac_m.shfile to anyhwere you like. E.g.,/home/scripts.
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_m.shpressEnter. - For executing the script, type/ copy
/location/cpbac_m.shpressEnter. - REMEMBER! cpbac_m.sh is not suitable for crontab/ systemd timer!.
This is a verbal representation of the script explaining how the script works.
For cpbac_a.sh:
-
Script will start executing and shows
[CyberPanel BAC] BACKUP ARCHIVE(S) COPIER/ MOVER INITIATED.... -
Now it will check for
LOGGED IN AS ROOTand shows[CyberPanel BAC] CHECKING IF LOGGED IN AS ROOT....
- If user is
rootthen it will show[CyberPanel BAC] LOGGED IN AS ROOT!and go to next step. - If user is not
rootthen it will show[CyberPanel BAC] NOT LOGGED IN AS ROOT!,[CyberPanel BAC] YOU MUST BE LOGGED IN AS ROOT!and exit.
- Now it will find
BACKUP ARCHIVE(S)and shows[CyberPanel BAC] FINDING BACKUP ARCHIVE(S)....
- If it finds any
BACKUP ARCHIVE(S)then it will show[CyberPanel BAC] BACKUP ARCHIVE(S) FOUND!and go to next step. - If it does not finds any
BACKUP ARCHIVE(S)then it will show[CyberPanel BAC] NO BACKUP ARCHIVE(S) FOUND!,[CyberPanel BAC] CREATE BACKUP ARCHIVE(S) AT 'IP or domain:8090/backup/backupSite' THEN TRY AGAIN!and exit.
- Now it will check for
actionvalue.
- REMEMBER! IT WILL OVERWRITE ANY FILE ON DESTINATION DIRECTORY IF NAME IS MATCHED! YOU HAVE BEEN WARNED!
For copy:
-
If
actionvalue is set toc, Cand destination directory is available then it will copy and shows[CyberPanel BAC] COPY IS ENABLED!,[CyberPanel BAC] DESTINATION DIRECTORY FOUND!,[CyberPanel BAC] COPYING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING COPIED BACKUP ARCHIVE(S),[CyberPanel BAC] COPYING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If
actionvalue is set toc, Cand destination directory is not available then it will copy and shows[CyberPanel BAC] COPY IS ENABLED!,[CyberPanel BAC] DESTINATION DIRECTORY NOT FOUND!,[CyberPanel BAC] CREATING DIRECTORY...,[CyberPanel BAC] DIRECTORY CREATED AT '/cp_sites_backups'!,[CyberPanel BAC] COPYING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING COPIED BACKUP ARCHIVE(S),[CyberPanel BAC] COPYING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit.
For move:
-
If
actionvalue is set tom, Mand destination directory is available then it will move and shows[CyberPanel BAC] MOVE IS ENABLED!,[CyberPanel BAC] MOVING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING MOVED BACKUP ARCHIVE(S),[CyberPanel BAC] MOVING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If
actionvalue is set tom, Mand destination directory is not available then it will move and shows[CyberPanel BAC] MOVE IS ENABLED!,[CyberPanel BAC] DIRECTORY NOT FOUND!,[CyberPanel BAC] CREATING DIRECTORY...,[CyberPanel BAC] DIRECTORY CREATED AT '/cp_sites_backups'!,[CyberPanel BAC] MOVING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING MOVED BACKUP ARCHIVE(S),[CyberPanel BAC] MOVING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit.
- If
actionvalue is notc, C, m, Mthen it will show[CyberPanel BAC] INVALID ACTION VALUE!and exit.
For cpbac_m.sh:
-
Script will start executing and shows
[CyberPanel BAC] BACKUP ARCHIVE(S) COPIER/ MOVER INITIATED.... -
Now it will check for
LOGGED IN AS ROOTand shows[CyberPanel BAC] CHECKING IF LOGGED IN AS ROOT....
- If user is
rootthen it will show[CyberPanel BAC] LOGGED IN AS ROOT!and go to next step. - If user is not
rootthen it will show[CyberPanel BAC] NOT LOGGED IN AS ROOT!,[CyberPanel BAC] YOU MUST BE LOGGED IN AS ROOT!and exit.
- Now it will find
BACKUP ARCHIVE(S)and shows[CyberPanel BAC] FINDING BACKUP ARCHIVE(S)....
- If it finds any
BACKUP ARCHIVE(S)then it will show[CyberPanel BAC] BACKUP ARCHIVE(S) FOUND!and go to next step. - If it does not finds any
BACKUP ARCHIVE(S)then it will show[CyberPanel BAC] NO BACKUP ARCHIVE(S) FOUND!,[CyberPanel BAC] CREATE BACKUP ARCHIVE(S) AT 'IP or domain:8090/backup/backupSite' THEN TRY AGAIN!and exit.
- Now it will show a prompt
[CyberPanel BAC] DO YOU WANT TO COPY/ MOVE BACKUP ARCHIVE(S) (c/m)?.
- REMEMBER! IT WILL OVERWRITE ANY FILE ON DESTINATION DIRECTORY IF NAME IS MATCHED! YOU HAVE BEEN WARNED!
For copy:
-
If user types
c, Cthen it will show another prompt[CyberPanel BAC] ARE YOU SURE (y/n)?. -
If user types
y, Yand destination directory is available thencopyfunction will be executed and shows[CyberPanel BAC] DESTINATION DIRECTORY FOUND!,[CyberPanel BAC] COPYING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING COPIED BACKUP ARCHIVE(S),[CyberPanel BAC] COPYING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If user types
n, Nthen it will exit. -
If user types something other than
y, Y, n, Nthen it will show[CyberPanel BAC] INVALID INPUT!and exit. -
If user types
y, Yand destination directory is not available thencopyfunction will be executed and shows[CyberPanel BAC] DESTINATION DIRECTORY NOT FOUND!,[CyberPanel BAC] CREATING DIRECTORY...,[CyberPanel BAC] DIRECTORY CREATED AT '/cp_sites_backups'!,[CyberPanel BAC] COPYING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING COPIED BACKUP ARCHIVE(S),[CyberPanel BAC] COPYING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If user types
n, Nthen it will exit. -
If user types something other than
y, Y, n, Nthen it will show[CyberPanel BAC] INVALID INPUT!and exit.
For move:
-
If user types
m, Mthen it will show another prompt[CyberPanel BAC] ARE YOU SURE (y/n)?. -
If user types
y, Yand backup directory is available thenmovefunction will be executed and shows[CyberPanel BAC] MOVING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING MOVED BACKUP ARCHIVE(S),[CyberPanel BAC] MOVING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If user types
n, Nthen it will exit. -
If user types something other than
y, Y, n, Nin the second prompt then it will show[CyberPanel BAC] INVALID INPUT!and exit. -
If user types
y, Yand backup directory is not available thenmovefunction will be executed and shows[CyberPanel BAC] DIRECTORY NOT FOUND!,[CyberPanel BAC] CREATING DIRECTORY...,[CyberPanel BAC] DIRECTORY CREATED AT '/cp_sites_backups'!,[CyberPanel BAC] MOVING BACKUP ARCHIVE(S)...,[CyberPanel BAC] LISTING MOVED BACKUP ARCHIVE(S),[CyberPanel BAC] MOVING ARCHIVE(S) COMPLETED!,[CyberPanel BAC] YOU WILL FIND BACKUP ARCHIVE(S) AT '/cp_sites_backups' DIRECTORY!and exit. -
If user types
n, Nthen it will exit. -
If user types something other than
y, Y, n, Nin the second prompt then it will show[CyberPanel BAC] INVALID INPUT!and exit. -
If user types something other than
c, C, m, Min the first prompt then it will show[CyberPanel BAC] INVALID INPUT!and exit.
- I have written the instructions based on CentOS 7.6.x.
- Files name are started with
0, 1, 2, 3, 4because of orderly manner. - I am new to this Scripting Business that's why if I made any mistake please point out any issue!
- I will update it frequently!