Download platform/signalcore/backup_to_github.sh from LevelUp2x/adaptai: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/main/platform/signalcore/backup_to_github.sh
- Command line
-
hf download hf://datasets/LevelUp2x/adaptai/platform/signalcore/backup_to_github.sh
-
curl -L -o backup_to_github.sh https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/main/platform/signalcore/backup_to_github.sh
2.33 kB
| # Automated backup script for SignalCore repository | |
| # Runs every 15 minutes to ensure all work is versioned and backed up | |
| # Configuration | |
| REPO_DIR="/data/adaptai/platform/signalcore" | |
| LOG_FILE="/data/adaptai/platform/signalcore/backup.log" | |
| MAX_LOG_SIZE=10485760 # 10MB | |
| # Colors for output | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| RED='\033[0;31m' | |
| NC='\033[0m' # No Color | |
| # Log function | |
| log() { | |
| echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE" | |
| } | |
| # Error function | |
| error() { | |
| echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR: $1" | tee -a "$LOG_FILE" | |
| exit 1 | |
| } | |
| # Rotate log if too large | |
| rotate_log() { | |
| if [ -f "$LOG_FILE" ] && [ $(stat -c%s "$LOG_FILE") -gt $MAX_LOG_SIZE ]; then | |
| mv "$LOG_FILE" "${LOG_FILE}.$(date +%Y%m%d_%H%M%S)" | |
| log "Rotated log file" | |
| fi | |
| } | |
| # Main backup function | |
| backup_repository() { | |
| cd "$REPO_DIR" || error "Cannot change to repository directory" | |
| log "Starting automated backup of SignalCore repository..." | |
| # Check if there are changes | |
| if git diff --quiet && git diff --staged --quiet; then | |
| log "${YELLOW}No changes to commit${NC}" | |
| return 0 | |
| fi | |
| # Add all changes | |
| git add . || error "Failed to add changes" | |
| # Commit with descriptive message | |
| COMMIT_MESSAGE="Auto-backup: $(date '+%Y-%m-%d %H:%M:%S') - SignalCore work" | |
| git commit -m "$COMMIT_MESSAGE" || error "Failed to commit changes" | |
| # Push to both branches | |
| git push origin main || error "Failed to push main branch" | |
| git push origin development || error "Failed to push development branch" | |
| log "${GREEN}Backup completed successfully${NC}" | |
| log "Changes committed and pushed to GitHub" | |
| # Show brief status | |
| git status --short | head -10 | while read line; do | |
| log " $line" | |
| done | |
| } | |
| # Main execution | |
| main() { | |
| rotate_log | |
| log "=== Starting SignalCore Backup ===" | |
| # Check if git is available | |
| if ! command -v git &> /dev/null; then | |
| error "Git is not available" | |
| fi | |
| # Check if in repository | |
| if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
| error "Not in a git repository" | |
| fi | |
| # Perform backup | |
| backup_repository | |
| log "=== Backup Completed ===" | |
| echo "" >> "$LOG_FILE" | |
| } | |
| # Run main function | |
| main "$@" |