Created
February 6, 2020 21:45
-
-
Save austinginder/258534c937dfe00a13147a0f775ba942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( count ( $args ) == 0 ) { | |
echo "Error: missing <captain_id> argument."; | |
return; | |
} | |
$json = $_SERVER['HOME'] . "/.captaincore-cli/config.json"; | |
$config_data = json_decode ( file_get_contents( $json ) ); | |
$system = $config_data[0]->system; | |
$path = $system->path; | |
$captain_id = $args[0]; | |
if ( $system->captaincore_fleet == "true" ) { | |
$path = "{$path}/$captain_id"; | |
} | |
$ids_sites_json = "ids-sites_{$captain_id}.json"; | |
if ( ! file_exists( $ids_sites_json ) ) { | |
echo "Error: missing file $ids_sites_json"; | |
return; | |
} | |
$sites = json_decode( file_get_contents( $ids_sites_json ) ); | |
foreach( $sites as $site ) { | |
if ( ! empty( $site->new_id ) && ! empty( $site->legacy_id ) ) { | |
$lookup = ( new CaptainCore\Sites )->get( $site->new_id ); | |
// Skip records missing site field | |
if ( empty( $lookup->site ) ) { | |
continue; | |
} | |
$directory = "{$lookup->site}_{$site->legacy_id}"; | |
$directory_new = "{$lookup->site}_{$site->new_id}"; | |
// Skip records missing site field | |
if ( empty( $lookup->site ) ) { | |
continue; | |
} | |
// Check for remote B2 Directory | |
echo "rclone move B2:CaptainCoreArchive/Snapshots/$captain_id/$directory B2:CaptainCoreArchive/Snapshots/$captain_id/$directory_new --progress\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment