- NO LONGER MAINTAINED!
- These scripts will copy/ move CyberPanel backup archive(s) from
/home/domain/backup
directory 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.sh
file to anyhwere you like. E.g.,/home/scripts
.
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_a.sh
pressEnter
. - For executing the script, type/ copy
/location/cpbac_a.sh
pressEnter
. - 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.sh
pressEnter
. - Open crontab, type/ copy
crontab -e
pressEnter
. - 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
Esc
and typewq
then pressEnter
. - Setting up cron is completed!
For systemd timer:
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_a.sh
pressEnter
. - Create a systemd service unit, type/ copy
/etc/systemd/system/cpbac_a.service
pressEnter
. - Copy all of the content from
cpbac_a.service
down below. - After setting service unit press
Esc
and typewq
then pressEnter
. - Create a systemd timer unit at the same location of service unit, type/ copy
/etc/systemd/system/cpbac_a.timer
pressEnter
. - Copy all of the content from
cpbac_a.timer
down below. - If you want to run the timer unit every day at 12AM, edit/ copy
*-*-* 00:00:00
(This is given on thecpbac_a.timer
file). - 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
Esc
and typewq
then 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.sh
file to anyhwere you like. E.g.,/home/scripts
.
- Open terminal.
- Give the file execute permission, type/ copy
sudo chmod +x /location/cpbac_m.sh
pressEnter
. - For executing the script, type/ copy
/location/cpbac_m.sh
pressEnter
. - 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 ROOT
and shows[CyberPanel BAC] CHECKING IF LOGGED IN AS ROOT...
.
- If user is
root
then it will show[CyberPanel BAC] LOGGED IN AS ROOT!
and go to next step. - If user is not
root
then 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
action
value.
- REMEMBER! IT WILL OVERWRITE ANY FILE ON DESTINATION DIRECTORY IF NAME IS MATCHED! YOU HAVE BEEN WARNED!
For copy:
-
If
action
value is set toc, C
and 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
action
value is set toc, C
and 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
action
value is set tom, M
and 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
action
value is set tom, M
and 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
action
value is notc, C, m, M
then 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 ROOT
and shows[CyberPanel BAC] CHECKING IF LOGGED IN AS ROOT...
.
- If user is
root
then it will show[CyberPanel BAC] LOGGED IN AS ROOT!
and go to next step. - If user is not
root
then 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, C
then it will show another prompt[CyberPanel BAC] ARE YOU SURE (y/n)?
. -
If user types
y, Y
and destination directory is available thencopy
function 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, N
then it will exit. -
If user types something other than
y, Y, n, N
then it will show[CyberPanel BAC] INVALID INPUT!
and exit. -
If user types
y, Y
and destination directory is not available thencopy
function 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, N
then it will exit. -
If user types something other than
y, Y, n, N
then it will show[CyberPanel BAC] INVALID INPUT!
and exit.
For move:
-
If user types
m, M
then it will show another prompt[CyberPanel BAC] ARE YOU SURE (y/n)?
. -
If user types
y, Y
and backup directory is available thenmove
function 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, N
then it will exit. -
If user types something other than
y, Y, n, N
in the second prompt then it will show[CyberPanel BAC] INVALID INPUT!
and exit. -
If user types
y, Y
and backup directory is not available thenmove
function 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, N
then it will exit. -
If user types something other than
y, Y, n, N
in the second prompt then it will show[CyberPanel BAC] INVALID INPUT!
and exit. -
If user types something other than
c, C, m, M
in 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, 4
because 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!