Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 19, 2024
1 parent 0bc3d9f commit 23fe19b
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions scripts/master_move_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,31 +662,35 @@


// First we get the files of the source to move
$command="rsync";
$param=array();
$command = "rsync";
$param = array();
//if (! in_array($mode, array('confirm', 'confirmredirect', 'confirmmaintenance'))) $param[]="-n";
//$param[]="-a";
if (! in_array($mode, array('diff','diffadd','diffchange'))) {
$param[]="-rlt";
$param[] = "-rlt";
} else {
$param[]="-rlD";
$param[]="--modify-window=1000000000";
$param[]="--delete -n";
$param[] = "-rlD";
$param[] = "--modify-window=1000000000";
$param[] = "-n";
}

//$param[]="-v";
if (empty($createthirdandinstance)) {
$param[]="-u";
$param[] = "-u";
} // If we have just created instance, we overwrite file during rsync
$param[]="--exclude .buildpath";
$param[]="--exclude .git";
$param[]="--exclude .gitignore";
$param[]="--exclude .settings";
$param[]="--exclude .project";
$param[]="--exclude *.pdf_preview.png";
$param[]="--exclude htdocs/conf/conf.php";
$param[]="--exclude glpi_config/config_db.php";
$param[]="--exclude htdocs/inc/downstream.php";
$param[]="-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'";
$param[] = "--exclude .buildpath";
$param[] = "--exclude .git";
$param[] = "--exclude .gitignore";
$param[] = "--exclude .settings";
$param[] = "--exclude .project";
$param[] = "--exclude *.pdf_preview.png";
$param[] = "--exclude htdocs/conf/conf.php";
$param[] = "--exclude glpi_config/config_db.php";
$param[] = "--exclude htdocs/inc/downstream.php";

$param[] = "--delete";

$param[] = "-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'";

$param[]=$oldosuser.'@'.$oldoshost.":".$sourcedir.'/*';
$param[]=$tmptargetdir;
Expand Down Expand Up @@ -737,11 +741,10 @@
//$param[]="-a";
if (! in_array($mode, array('diff','diffadd','diffchange'))) {
$param[] = "-rlt";
$param[] = "--delete"; // Delete existing files not into source and not into the --exclude parameters
} else {
$param[] = "-rlD";
$param[] = "--modify-window=1000000000";
$param[] = "--delete -n";
$param[] = "-n";
}
//$param[] = "-v";
if (empty($createthirdandinstance)) {
Expand All @@ -755,6 +758,12 @@
$param[] = "--exclude htdocs/conf/conf.php";
$param[] = "--exclude glpi_config/config_db.php";
$param[] = "--exclude htdocs/inc/downstream.php";

if (!$overwriteexistinginstance) {
// There is no existing instance so no risk to delete data we want to keep. So we can use --delete.
$param[] = "--delete"; // Delete existing files not into source and not into the --exclude parameters
}

$param[] = "-e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'";

$param[] = $sourcedir.'/';
Expand Down

0 comments on commit 23fe19b

Please sign in to comment.