You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(backup): support older rclone on restore and add a --list preflight
Two robustness follow-ups to the rclone memory-budgeting work merged in #477:
1) Restore on older rclone (regression). rclone_download() unconditionally passed --multi-thread-write-buffer-size (added in rclone v1.63.0) and --multi-thread-chunk-size (added in v1.64.0). Older rclone hard-fails on unknown flags (Fatal error: unknown flag, exit code 2), so any rclone < 1.63 -- common in distro packages -- broke restore/rollback. Both flags are now gated behind the detected rclone version (get_rclone_version()), with thresholds in RCLONE_MIN_VERSION_MT_* constants. The memory budget already assumes their defaults, so gating them out changes only which knobs reach rclone, not the computed footprint; --transfers/--buffer-size/--multi-thread-streams (all >= v1.48, long-standing) are always passed. When the version cannot be determined, the newer flags are skipped (safe).
2) Friendly preflight on read paths. The rclone-presence and backend-config checks lived inside pre_backup_restore_checks(), which the 'backup --list' branch and the 'restore --id' branch (via verify_backup_id() -> rclone lsf) both reach before, so a missing rclone surfaced as a raw 'sh: 1: rclone: not found' (--list) or a misleading 'Invalid backup ID' (restore --id). Extracted the checks into check_rclone_available() and call it on both read paths (and from pre_backup_restore_checks() for the main backup/restore flows).
@@ -65,6 +72,7 @@ public function backup( $args, $assoc_args = [] ) {
65
72
66
73
// Handle --list flag to display available backups
67
74
if ( $list_backups ) {
75
+
$this->check_rclone_available();
68
76
$this->list_remote_backups();
69
77
70
78
return; // Exit after listing backups
@@ -263,6 +271,12 @@ public function restore( $args, $assoc_args = [] ) {
263
271
264
272
if ( $backup_id ) {
265
273
274
+
// verify_backup_id() lists remote backups (rclone lsf) before the
275
+
// pre_restore_check() preflight below, so check rclone here too --
276
+
// otherwise a missing rclone surfaces as a misleading "Invalid backup
277
+
// ID" instead of the friendly "rclone is not installed" message.
278
+
$this->check_rclone_available();
279
+
266
280
if ( ! $this->verify_backup_id( $backup_id ) ) {
267
281
EE::error( "Invalid backup ID provided.\nPlease provide a valid ID from the list using 'ee site backup --list " . $this->site_data['site_url'] . "'." );
268
282
}
@@ -865,7 +879,14 @@ private function restore_wp( $backup_dir ) {
865
879
EE::run_command( $args, $assoc_args, $options );
866
880
}
867
881
868
-
privatefunctionpre_backup_restore_checks() {
882
+
/**
883
+
* Verify rclone is installed and the configured backend exists.
884
+
*
885
+
* Extracted from pre_backup_restore_checks() so read-only paths (e.g.
886
+
* `ee site backup --list`) can run it before invoking rclone and surface a
887
+
* friendly message instead of a raw "sh: 1: rclone: not found".
888
+
*/
889
+
privatefunctioncheck_rclone_available() {
869
890
$command = 'rclone --version';
870
891
$return_code = EE::exec( $command );
871
892
@@ -893,6 +914,10 @@ private function pre_backup_restore_checks() {
893
914
);
894
915
EE::error( sprintf( 'rclone backend "%s" does not exist. Please create it using `rclone config`', $rclone_backend ) );
895
916
}
917
+
}
918
+
919
+
privatefunctionpre_backup_restore_checks() {
920
+
$this->check_rclone_available();
896
921
897
922
$this->check_and_install( 'zip', 'zip' );
898
923
$this->check_and_install( '7z', 'p7zip-full' );
@@ -1286,6 +1311,20 @@ private function get_available_ram_mb() {
1286
1311
returnintval( EE::launch( $command )->stdout );
1287
1312
}
1288
1313
1314
+
/**
1315
+
* Installed rclone version as a dotted string (e.g. "1.66.0"), or '' if it
1316
+
* cannot be determined. Used to gate download flags that older rclone lacks.
1317
+
*
1318
+
* @return string
1319
+
*/
1320
+
privatefunctionget_rclone_version() {
1321
+
// `rclone version` prints e.g. "rclone v1.66.0" on its first line.
1322
+
$output = EE::launch( "rclone version | head -n1 | awk '{print $2}'" )->stdout;
0 commit comments