Fix backup file creation - only backup when overwriting existing files
- Removed backup logic from localize_yml_file function - Added backup checks before file copy in all deploy functions - Backups now only created when docker-compose.yml already exists - Prevents unnecessary .backup files on first deployment
This commit is contained in:
@@ -147,11 +147,7 @@ localize_yml_file() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup only if target file already exists (not for repo sources)
|
# Backup logic removed - handled before file copy in deploy functions
|
||||||
if [[ "$file_path" != "$REPO_DIR"* ]] && [ -f "$file_path" ]; then
|
|
||||||
cp "$file_path" "$file_path.backup.$(date +%Y%m%d_%H%M%S)"
|
|
||||||
debug_log "Backed up $file_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use envsubst to replace all ${VAR} with environment values, handling nested variables
|
# Use envsubst to replace all ${VAR} with environment values, handling nested variables
|
||||||
if command -v envsubst >/dev/null 2>&1; then
|
if command -v envsubst >/dev/null 2>&1; then
|
||||||
@@ -969,6 +965,11 @@ deploy_dockge() {
|
|||||||
log_info " - Dockge (Docker Compose Manager)"
|
log_info " - Dockge (Docker Compose Manager)"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Backup existing files if they exist
|
||||||
|
if [ -f /opt/dockge/docker-compose.yml ]; then
|
||||||
|
sudo cp /opt/dockge/docker-compose.yml /opt/dockge/docker-compose.yml.backup.$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy Dockge stack files
|
# Copy Dockge stack files
|
||||||
sudo cp "$REPO_DIR/docker-compose/dockge/docker-compose.yml" /opt/dockge/docker-compose.yml
|
sudo cp "$REPO_DIR/docker-compose/dockge/docker-compose.yml" /opt/dockge/docker-compose.yml
|
||||||
sudo cp "$REPO_DIR/.env" /opt/dockge/.env
|
sudo cp "$REPO_DIR/.env" /opt/dockge/.env
|
||||||
@@ -1002,6 +1003,12 @@ deploy_core() {
|
|||||||
|
|
||||||
# Copy core stack files
|
# Copy core stack files
|
||||||
debug_log "Copying core stack files"
|
debug_log "Copying core stack files"
|
||||||
|
|
||||||
|
# Backup existing files if they exist
|
||||||
|
if [ -f /opt/stacks/core/docker-compose.yml ]; then
|
||||||
|
sudo cp /opt/stacks/core/docker-compose.yml /opt/stacks/core/docker-compose.yml.backup.$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
|
|
||||||
sudo cp "$REPO_DIR/docker-compose/core/docker-compose.yml" /opt/stacks/core/docker-compose.yml
|
sudo cp "$REPO_DIR/docker-compose/core/docker-compose.yml" /opt/stacks/core/docker-compose.yml
|
||||||
sudo cp "$REPO_DIR/.env" /opt/stacks/core/.env
|
sudo cp "$REPO_DIR/.env" /opt/stacks/core/.env
|
||||||
sudo chown "$ACTUAL_USER:$ACTUAL_USER" /opt/stacks/core/docker-compose.yml
|
sudo chown "$ACTUAL_USER:$ACTUAL_USER" /opt/stacks/core/docker-compose.yml
|
||||||
@@ -1146,6 +1153,11 @@ deploy_infrastructure() {
|
|||||||
log_info " - Docker Proxy (Security)"
|
log_info " - Docker Proxy (Security)"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Backup existing files if they exist
|
||||||
|
if [ -f /opt/stacks/infrastructure/docker-compose.yml ]; then
|
||||||
|
cp /opt/stacks/infrastructure/docker-compose.yml /opt/stacks/infrastructure/docker-compose.yml.backup.$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy infrastructure stack
|
# Copy infrastructure stack
|
||||||
cp "$REPO_DIR/docker-compose/infrastructure/docker-compose.yml" /opt/stacks/infrastructure/docker-compose.yml
|
cp "$REPO_DIR/docker-compose/infrastructure/docker-compose.yml" /opt/stacks/infrastructure/docker-compose.yml
|
||||||
cp "$REPO_DIR/.env" /opt/stacks/infrastructure/.env
|
cp "$REPO_DIR/.env" /opt/stacks/infrastructure/.env
|
||||||
@@ -1204,6 +1216,11 @@ deploy_dashboards() {
|
|||||||
# Create dashboards directory
|
# Create dashboards directory
|
||||||
sudo mkdir -p /opt/stacks/dashboards
|
sudo mkdir -p /opt/stacks/dashboards
|
||||||
|
|
||||||
|
# Backup existing files if they exist
|
||||||
|
if [ -f /opt/stacks/dashboards/docker-compose.yml ]; then
|
||||||
|
cp /opt/stacks/dashboards/docker-compose.yml /opt/stacks/dashboards/docker-compose.yml.backup.$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy dashboards compose file
|
# Copy dashboards compose file
|
||||||
cp "$REPO_DIR/docker-compose/dashboards/docker-compose.yml" /opt/stacks/dashboards/docker-compose.yml
|
cp "$REPO_DIR/docker-compose/dashboards/docker-compose.yml" /opt/stacks/dashboards/docker-compose.yml
|
||||||
cp "$REPO_DIR/.env" /opt/stacks/dashboards/.env
|
cp "$REPO_DIR/.env" /opt/stacks/dashboards/.env
|
||||||
@@ -1271,6 +1288,11 @@ deploy_arcane() {
|
|||||||
# Create arcane directory
|
# Create arcane directory
|
||||||
sudo mkdir -p /opt/arcane
|
sudo mkdir -p /opt/arcane
|
||||||
|
|
||||||
|
# Backup existing files if they exist
|
||||||
|
if [ -f /opt/arcane/docker-compose.yml ]; then
|
||||||
|
sudo cp /opt/arcane/docker-compose.yml /opt/arcane/docker-compose.yml.backup.$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy arcane compose file
|
# Copy arcane compose file
|
||||||
sudo cp "$REPO_DIR/docker-compose/arcane/docker-compose.yml" /opt/arcane/docker-compose.yml
|
sudo cp "$REPO_DIR/docker-compose/arcane/docker-compose.yml" /opt/arcane/docker-compose.yml
|
||||||
sudo cp "$REPO_DIR/.env" /opt/arcane/.env
|
sudo cp "$REPO_DIR/.env" /opt/arcane/.env
|
||||||
|
|||||||
Reference in New Issue
Block a user