mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-23 01:50:05 +08:00
49 lines
No EOL
1.2 KiB
Bash
49 lines
No EOL
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Fetches list of snapshots for a site from a backup repo
|
|
#
|
|
# `captaincore backup list <site>`
|
|
#
|
|
|
|
if [ ${#@} -eq 0 ]; then
|
|
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Requires a <site>"
|
|
exit
|
|
fi
|
|
|
|
while read config; do
|
|
if [[ "$config" == "Error:"* ]]; then
|
|
continue
|
|
fi
|
|
declare "$config"
|
|
done <<< "$(php ${CAPTAINCORE_PATH}/lib/local-scripts/configs.php fetch)"
|
|
|
|
site=$1
|
|
|
|
run_command() {
|
|
|
|
# Extract environment
|
|
if [[ "$site" == *"-staging"* ]]; then
|
|
environment=staging
|
|
fi
|
|
|
|
if [[ "$site" == *"-production"* ]]; then
|
|
environment=production
|
|
fi
|
|
|
|
if [[ "$site" != *"-"* ]]; then
|
|
environment=production
|
|
fi
|
|
|
|
# Load site configs
|
|
while read site_configs; do if [[ $site_configs == "" ]]; then continue; fi; declare "$site_configs"; done <<< "$(captaincore site get $site --bash --captain-id=$CAPTAIN_ID)"
|
|
|
|
backup_list="$path/${site}_${site_id}/${environment}/backups/list.json"
|
|
if [ ! -f "$backup_list" ] || [[ $( stat --printf="%s" $path/${site}_${site_id}/${environment}/backups/list.json ) == "0" ]]; then
|
|
captaincore backup list-generate $site-$environment --captain-id=$CAPTAIN_ID
|
|
fi
|
|
cat "$backup_list"
|
|
|
|
}
|
|
|
|
run_command |