├── .gitignore
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── ScreenShots
├── Create.png
├── Options.png
├── Overview.png
└── Settings.png
├── admin
├── elements
│ ├── conf
│ │ ├── DEFAULT.ini
│ │ └── directadmin.ini.sample
│ ├── footer.php
│ ├── functions.php
│ ├── header.php
│ ├── lang
│ │ └── English.php
│ ├── language.php
│ ├── menu.php
│ ├── notification.php
│ ├── page.php
│ ├── pages
│ │ ├── create.php
│ │ ├── options.php
│ │ ├── overview.php
│ │ └── settings.php
│ ├── process
│ │ ├── process_croncreate.php
│ │ ├── process_options.php
│ │ └── process_settings.php
│ └── scripts
│ │ ├── backup_job.sh
│ │ ├── bash_ini_parser
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── README
│ │ ├── TODO
│ │ └── read_ini.sh
│ │ ├── manage_cron.sh
│ │ ├── send_mail.sh
│ │ ├── software_check.sh
│ │ └── update_ini.sh
└── index.html
├── hooks
└── admin_txt.html
├── images
├── css
│ └── default.css
└── js
│ └── default.js
├── plugin.conf
├── rclone_backup.tar.gz
├── scripts
├── install.sh
├── uninstall.sh
└── update.sh
└── version.html
/.gitignore:
--------------------------------------------------------------------------------
1 | admin/elements/conf/directadmin.ini
2 | gzip.bat
3 | .idea
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [v1.0.8](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.8) (2022-06-28)
4 |
5 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.7...v1.0.8)
6 |
7 | **Implemented enhancements:**
8 |
9 | - Remove required from email when creating/editing job.
10 | - Code cleanup
11 | - Fix backup_up script exiting with code 127
12 | - Added option to delete cron from overview page
13 | - Added option to specify mysql login for use with .my.conf or mysql_config_editor
14 |
15 | ## [v1.0.7](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.7) (2022-01-22)
16 |
17 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.6...v1.0.7)
18 |
19 | **Implemented enhancements:**
20 |
21 | - Code cleanup
22 | - Changed API command to get document roots for all users
23 | - Fix for SSL not verifying certificate
24 |
25 | ## [v1.0.6](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.6) (2022-01-22)
26 |
27 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.5...v1.0.6)
28 |
29 | **Implemented enhancements:**
30 |
31 | - Amended README
32 | - Fix for error on install.
33 | - Directadmin.ini no longer overwritten on install/update.
34 |
35 | ## [v1.0.5](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.5) (2022-01-18)
36 |
37 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.4...v1.0.5)
38 |
39 | **Implemented enhancements:**
40 |
41 | - Fix conf folders not being created.
42 |
43 | ## [v1.0.4](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.4) (2022-01-17)
44 |
45 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.3...v1.0.4)
46 |
47 | **Implemented enhancements:**
48 |
49 | - Fix cron create page not loading.
50 | - Code cleanup.
51 |
52 | ## [v1.0.3](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.3) (2022-01-17)
53 |
54 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.2...v1.0.3)
55 |
56 | **Implemented enhancements:**
57 |
58 | - Fix update scripts.
59 |
60 | ## [v1.0.2](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.2) (2022-01-17)
61 |
62 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.1...v1.0.2)
63 |
64 | **Implemented enhancements:**
65 |
66 | - Stored version.html on GitHub for easier updating.
67 | - [Updated plugin.conf to reflect version changes](https://github.com/adrianb11/directadmin_rclone_backup/tree/master/plugin.conf)
68 |
69 | ## [v1.0.1](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.1) (2021-01-17)
70 |
71 | [Full Changelog](https://github.com/adrianb11/directadmin_rclone_backup/compare/v1.0.0...v1.0.1)
72 |
73 | **Implemented enhancements:**
74 |
75 | - [Added ScreenShots](https://github.com/adrianb11/directadmin_rclone_backup/tree/master/ScreenShots)
76 | - [Added README.md](README.md)
77 |
78 | ## [v1.0.0](https://github.com/adrianb11/directadmin_rclone_backup/tree/v1.0.0) (2021-01-16)
79 |
80 | **Initial Release**
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 adrianb11
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DirectAdmin RClone Backup Interface
2 |
3 | 
4 | [](LICENSE.md)
5 | [](https://scrutinizer-ci.com/g/adrianb11/directadmin_rclone_backup/?branch=master)
6 |
7 | ## Description
8 |
9 | This is a DirectAdmin plugin that creates Cron Jobs to backup files/databases and uses RClone to upload them to a
10 | filehost.
11 |
12 | * Files can be compressed into zip, tar, and gzip formats.
13 | * MySQL, PostgreSQL, and MongoDB databases are supported.
14 |
15 | This was built to make my life easier and because of this, is tailored more to my needs.
16 |
17 | Built for DirectAdmin 1.61.5 using Evolution skin. I can not guarantee other DA versions or skins will work correctly. I
18 | have also only tested this with Dropbox but other hosts should work too. My DA license is only for 1 account, so I
19 | haven't tested this on a multi account server.
20 |
21 | **Warning** - This plugin adds jobs to the root crontab and runs shell scripts as root. This is so all domains can be
22 | backed up from a single account. This also makes backing up databases easier as password does not need to be recorded.
23 | While this is not strictly necessary on a single account license (can be run as admin), files not accessible by admin
24 | cannot be backed up. If this makes you nervous, please do not install.
25 |
26 | ### Requirements
27 |
28 | * [RClone](https://github.com/rclone/rclone)
29 | * RClone remotes already created.
30 |
31 | ### Installation
32 |
33 | To install, simple download the package and install via the package manager in DirectAdmin. During installation, this
34 | plugin will check if RClone and other packages are installed
35 |
36 | ### How It Works
37 |
38 | There are 4 main sections to this plugin:-
39 |
40 | * **Configuration files**
41 | * Each job has its details saved into an .ini file which is used for the actual backup process and to display
42 | details on the web interface.
43 | * **The web interface**
44 | * This allows you to create, edit jobs and view any jobs which have been created.
45 | * Jobs which have been created are separated into active, inactive, and pending categories.
46 | * Each job on the overview tab can be expanded to show its details.
47 | * **manage_cron script**
48 | * This shell script is used to manage any newly created or edited jobs.
49 | * On install, a new cronjob is added runs manage_cron.sh on a regular basis.
50 | * On each run, this will scan for any newly created or edited jobs and create a new cronjob for them.
51 | * The cron created will include a path to the .ini for that job.
52 | * **backup_job script**
53 | * This is responsible for the actual backup of files and execution of RClone.
54 | * The backup_job script will use the .ini file passed to create a backup of files and databases requested.
55 |
56 | ### Usage
57 |
58 | * **Once installed, check "View Settings" tab to view software installed.**
59 | * Software check can be re-run individually or collectively.
60 | * manage_cron.sh script can be run from here instead of waiting from scheduled cronjob to run.
61 | * **Enter default options in "View/Change Options" tab.**
62 | * Language Selection:-
63 | * Language: Any language files created will be displayed in this dropdown box.
64 | * Default Compression:-
65 | * Compression: Sets the default compression method to use.
66 | * File Host:-
67 | * File Host Root Path: Sets the root path where files should be uploaded. This will be appended with the full
68 | directory path created.
69 | * Email:-
70 | * Enabled: Sets whether emailed reports should be sent by default.
71 | * Default Send Email: This is the email address reports will be sent from.
72 | * RClone:-
73 | * Available Remotes: List all available remotes you wish to be used. All remotes must be separated by a comma.
74 | * Folder Structure: Sets the path to be appended to Root Path. Options are **Case Sensitive!**
75 | * **Create a new job on the "Create/Edit Cronjob" tab.**
76 | * Cron Creator:-
77 | * Selectable fields to create cronjob times.
78 | * Links to select every minute, hour, day, month, and week day.
79 | * Cron Preset Templates:-
80 | * Clickable preset templates which automatically fill in cron time.
81 | * Settings:-
82 | * Enabled: Sets whether this job should be enabled (creates ini and cronjob) or disabled (creates ini only).
83 | * File Host Root Path: Sets the root path where files should be uploaded. This will be appended with the full
84 | directory path created. Field taken from default option saved in options tab.
85 | * List of all remotes saved in options tab.
86 | * Folder Structure: Sets the path to be appended to Root Path. Options are **Case Sensitive!**. Field taken from
87 | default option saved in options tab.
88 | * DirectAdmin:-
89 | * DirectAdmin Username: A selectable list of all users.
90 | * DirectAdmin Domain: A selectable list of all domains. When a username is selected, this field will only show
91 | domains assigned to it.
92 | * DirectAdmin Sub-Domain: A selectable list of all sub-domains. When a domain is selected, this field will only
93 | show sub-domains assigned to it.
94 | * Backup Path: This is automatically generated based on the username, domain, and sub-domain fields. Field can
95 | be edited to backup a specific folder.
96 | * Exclude Path: Specify the full path to a folder you wish to exclude from the backup.
97 | * Database To Backup: A dropdown list of all databases.
98 | * Database Type: Select the database type.
99 | * Compression: Sets the compression method to use. Field taken from default option saved in options tab.
100 | * Email Log:-
101 | * Send Email Notifications: Sets whether a notification should be sent when cron is completed.
102 | * Email Address: The email address report should be sent to.
103 | * **View created jobs on "Cron Overview" tab.**
104 | * Active: Displays all active jobs.
105 | * Inactive: Displays all inactive jobs.
106 | * Pending: Displays all pending jobs.
107 |
108 | ### Support
109 |
110 | If you find any issues or have a feature
111 | request, [please create a new issue](https://github.com/adrianb11/directadmin_rclone_backup/issues).
112 |
113 | ### ScreenShots
114 |
115 | #### Overview
116 |
117 | 
118 |
119 | #### Create/Edit Cronjob
120 |
121 | 
122 |
123 | #### View/Change Options
124 |
125 | 
126 |
127 | #### View Settings
128 |
129 | 
130 |
131 | ### Acknowledgments
132 |
133 | - [Thomas Ba - Cron Expression Generator](https://github.com/thomasba/cron-expression-generator)
134 |
135 | ### License
136 |
137 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
--------------------------------------------------------------------------------
/ScreenShots/Create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adrianb11/directadmin_rclone_backup/78df562ea90126f8a6b1e66c133fa69c1c8e7094/ScreenShots/Create.png
--------------------------------------------------------------------------------
/ScreenShots/Options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adrianb11/directadmin_rclone_backup/78df562ea90126f8a6b1e66c133fa69c1c8e7094/ScreenShots/Options.png
--------------------------------------------------------------------------------
/ScreenShots/Overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adrianb11/directadmin_rclone_backup/78df562ea90126f8a6b1e66c133fa69c1c8e7094/ScreenShots/Overview.png
--------------------------------------------------------------------------------
/ScreenShots/Settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adrianb11/directadmin_rclone_backup/78df562ea90126f8a6b1e66c133fa69c1c8e7094/ScreenShots/Settings.png
--------------------------------------------------------------------------------
/admin/elements/conf/DEFAULT.ini:
--------------------------------------------------------------------------------
1 | [REFERENCE]
2 | in_progress = false
3 | last_ran =
4 | times_ran =
5 |
6 | [ACTIVE]
7 | active = false
8 |
9 | [CRON]
10 | cron_id = *
11 | cron_output_minutes = *
12 | cron_output_hours = *
13 | cron_output_dom = *
14 | cron_output_months = *
15 | cron_output_dow = *
16 |
17 | [RCLONE]
18 | remote =
19 | structure = UDSymd
20 |
21 | [FILEHOST]
22 | filehost_root_path =
23 |
24 | [DIRECTADMIN_WWW]
25 | directadmin_user =
26 | directadmin_domain =
27 | directadmin_subdomain =
28 | directadmin_backup_path =
29 | directadmin_exclude_path =
30 |
31 | [DIRECTADMIN_DB]
32 | database_name =
33 | database_type =
34 |
35 | [COMPRESSION]
36 | compression = gzip
37 |
38 | [EMAIL]
39 | send_email_enabled = false
40 | send_email_address =
41 |
--------------------------------------------------------------------------------
/admin/elements/conf/directadmin.ini.sample:
--------------------------------------------------------------------------------
1 | [SETTINGS]
2 | developmentmode = false
3 | version = 1.0.7
4 | ignore_certificate = 0
5 | my_conf_login =
6 | my_conf_enabled = 0
7 |
8 | [LANGUAGE]
9 | language = English
10 |
11 | [RCLONE]
12 | remotes =
13 | structure = UDSymd
14 |
15 | [FILEHOST]
16 | filehost_root_path =
17 |
18 | [DIRECTADMIN_WWW]
19 | directadmin_backup_tmp =
20 |
21 | [COMPRESSION]
22 | compression = tgz
23 |
24 | [EMAIL]
25 | send_email_enabled = false
26 | send_email_address =
27 |
28 | [INSTALLED]
29 | rclone_installed = false
30 | zip_installed = false
31 | mysql_installed = false
32 | postgresql_installed = false
33 | mongodb_installed = false
34 |
--------------------------------------------------------------------------------
/admin/elements/footer.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/admin/elements/functions.php:
--------------------------------------------------------------------------------
1 | $values) {
25 | //append the section
26 | $content .= "[" . $section . "]\n";
27 | //append the values
28 | foreach ($values as $key => $value) {
29 | $content .= $key . "=" . $value . "\n";
30 | }
31 | }
32 |
33 | //write it into file
34 | if (!$handle = fopen($filepath, 'w')) {
35 | return false;
36 | }
37 | $success = fwrite($handle, $content);
38 | fclose($handle);
39 | return $success;
40 | }
41 |
42 |
43 | /**
44 | * Get directory contents into array and return.
45 | * @param $dir
46 | * @return array
47 | */
48 | function GetDirContents($dir)
49 | {
50 | return array_diff(scandir($dir), array('.', '..'));
51 | }
52 |
53 |
54 | /**
55 | * Save POST to config_data variable
56 | * @param $config_data
57 | * @param $exclude
58 | * @param $post
59 | * @return array
60 | */
61 | function WriteConfigData($config_data, $exclude, $post)
62 | {
63 | foreach ($config_data as $sectionKEY => $sectionVALUE) {
64 |
65 | //Check if KEY is in exclude list
66 | if (!in_array($sectionKEY, $exclude)) {
67 | foreach ($sectionVALUE as $elementKEY => $elementVALUE) {
68 | if (isset($post[$elementKEY])) {
69 | $config_data[$sectionKEY][$elementKEY] = $post[$elementKEY];
70 | } else {
71 | $config_data[$sectionKEY][$elementKEY] = '';
72 | }
73 | }
74 | }
75 | }
76 | return $config_data;
77 | }
78 |
79 |
80 | /**
81 | * Function to communicate with DirectAdmin API without username and password.
82 | * Uses session data so user must be logged in.
83 | * @param $cmd
84 | * @return string
85 | */
86 | function getApi($cmd)
87 | {
88 | $directadminarray = ReadINI("/usr/local/directadmin/plugins/rclone_backup/admin/elements/conf/directadmin.ini");
89 |
90 | $addr = "";
91 |
92 | if ($_SERVER["SSL"] === "1")
93 | {
94 | $addr .= "https://";
95 | }
96 |
97 | $addr .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $cmd;
98 |
99 | try {
100 | $ch = curl_init($addr);
101 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
102 | curl_setopt($ch, CURLOPT_COOKIE, "session=" . $_SERVER["SESSION_ID"] . "; key=" . $_SERVER["SESSION_KEY"]);
103 |
104 | if ($directadminarray["SETTINGS"]["ignore_certificate"] === "1") {
105 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
106 | }
107 |
108 | $content = curl_exec($ch);
109 |
110 | // Check the return value of curl_exec()
111 | if ($content === false) {
112 | throw new Exception(curl_error($ch), curl_errno($ch));
113 | }
114 |
115 | return curl_exec($ch);
116 | } catch(Exception $e) {
117 |
118 | if ($e->getCode() == "60")
119 | {
120 | echo "Fatal error: Curl failed with error #60: Please enable ignore peer certificates in plugin options";
121 | } else {
122 | trigger_error(sprintf(
123 | 'Curl failed with error #%d: %s',
124 | $e->getCode(), $e->getMessage()),
125 | E_USER_ERROR);
126 | }
127 | } finally {
128 | // Close curl handle unless it failed to initialize
129 | if (is_resource($ch)) {
130 | curl_close($ch);
131 | }
132 | }
133 | }
134 |
135 | /**
136 | * Shortcut to print an array.
137 | * @param $array
138 | */
139 | function printArray($array)
140 | {
141 | echo "
";
142 | print_r($array);
143 | echo "
";
144 | }
--------------------------------------------------------------------------------
/admin/elements/header.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
11 |
12 |
13 |
15 |
16 | "Monday",
6 | "TUESDAY" => "Tuesday",
7 | "WEDNESDAY" => "Wednesday",
8 | "THURSDAY" => "Thursday",
9 | "FRIDAY" => "Friday",
10 | "SATURDAY" => "Saturday",
11 | "SUNDAY" => "Sunday",
12 |
13 | //Months
14 | "JANUARY" => "January",
15 | "FEBRUARY" => "February",
16 | "MARCH" => "March",
17 | "APRIL" => "April",
18 | "MAY" => "May",
19 | "JUNE" => "June",
20 | "JULY" => "July",
21 | "AUGUST" => "August",
22 | "SEPTEMBER" => "September",
23 | "OCTOBER" => "October",
24 | "NOVEMBER" => "November",
25 | "DECEMBER" => "December",
26 |
27 | //Times
28 | "MINUTES" => "Minutes",
29 | "EVERY_MINUTE" => "Every Minute",
30 | "HOURS" => "Hours",
31 | "EVERY_HOUR" => "Every Hour",
32 | "MONTH" => "Month",
33 | "EVERY_MONTH" => "Every Month",
34 | "WEEK_DAY" => "Week Day",
35 | "EVERY_WEEK_DAY" => "Every Week Day",
36 | "DAY_OF_MONTH" => "Day Of Month",
37 | "EVERY_DAY" => "Every Day",
38 | "SELECT_ALL" => "Select All",
39 | "EVERY_5_MINUTES" => "Every 5 Minutes",
40 | "EVERY_15_MINUTES" => "Every 15 Minutes",
41 | "EVERY_30_MINUTES" => "Every 30 Minutes",
42 | "EVERY_3_HOURS" => "Every 3 Hours",
43 | "EVERY_4_HOURS" => "Every 4 Hours",
44 | "EVERY_6_HOURS" => "Every 6 Hours",
45 | "EVERY_12_HOURS" => "Every 12 Hours",
46 | "EVERY_DAY_AT" => "Every Day At",
47 | "EVERY_SUNDAY_AT" => "Every Sunday At",
48 |
49 | //Status
50 | "ENABLED" => "Enabled",
51 | "DISABLED" => "Disabled",
52 | "active" => "Active",
53 | "inactive" => "Inactive",
54 | "pending" => "Pending",
55 | "NOT_INSTALLED" => "NOT INSTALLED",
56 | "INSTALLED" => "INSTALLED",
57 | "TRUE" => "True",
58 | "FALSE" => "False",
59 |
60 | //Page Titles
61 | "OVERVIEW_PAGE_TITLE" => "Cron Overview",
62 | "CREATE_NEW_CRONJOB_TITLE" => "Create/Edit Cronjob",
63 | "OPTIONS_PAGE_TITLE" => "View/Change Options",
64 | "SETTINGS_PAGE_TITLE" => "View Settings",
65 | "RCLONE_NOT_FOUND" => "RClone Not Found",
66 |
67 | //Sentences
68 | "RCLONE_NOT_FOUND_DESC" => "RClone was not found on your system. Please check if it is installed correctly.",
69 | "LANGUAGE_DESC" => "Please select a language file. All currently available languages will be displayed.",
70 | "COMPRESSION_DESC" => "Please select which compression method to use. Available options are: Zip, tar, and gzip.",
71 | "DEFAULT_FILEHOST_ROOT_PATH_DESC" => "Please enter the default file host root path.",
72 | "FILEHOST_ROOT_PATH_DESC" => "Please enter the file host root path.",
73 | "ENABLED_DESC" => "Please select whether this should be enabled or disabled.",
74 | "DEFAULT_EMAIL_DESC" => "Please enter the default email address reports should be sent from.",
75 | "EMAIL_DESC" => "Please enter the email address reports should be sent to.",
76 | "AVAILABLE_REMOTES_DESC" => "Please enter available remotes. Multiple remotes should be separated by a comma.",
77 | "AVAILABLE_REMOTES_SELECT_DESC" => "Please select a remote to use.",
78 | "DEFAULT_FOLDER_STRUCTURE_DESC" => "Please enter the folder structure to use.",
79 | "FOLDER_STRUCTURE_DESC" => 'Available options are: U D S o e a y m d
U = DirectAdmin Username (selected when creating new job)
D = DirectAdmin Domain (selected when creating new job)
S = DirectAdmin Sub-Domain (selected when creating new job)