Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Colors
- RED="\e[0;91m"
- GREEN="\e[0;92m"
- YELLOW="\e[0;93m"
- NC="\e[0m"
- # CHANGE ME
- railroaderDir="/opt/games/steam/steamapps/compatdata/1683150/pfx/drive_c/users/steamuser/AppData/LocalLow/Giraffe Lab LLC/Railroader/Saves"
- backupDir="/data/backup/savegames/Railroader"
- dateString=$(date +"%Y-%m-%d_%H-%M")
- if [[ ! -d "$backupDir" ]]; then
- mkdir "$backupDir"
- if [[ ! -d "$backupDir" ]]; then
- echo "Error creating backup directory: $backupDir"
- exit 1
- fi
- fi
- cd "$railroaderDir" || exit 1
- saves=(*.shortsave)
- for save in "${saves[@]}"; do
- if [[ ! "$save" =~ "_auto" && -f "$save" ]]; then
- save_hash=$(md5sum "$save" | cut -d' ' -f1)
- backup_file=$(ls "${backupDir}" | grep "${save}-" 2>/dev/null | tail -n1)
- backup="${backupDir}/${backup_file}"
- backup_hash=""
- if [[ -n "$backup" ]]; then
- backup_hash=$(md5sum "$backup" | cut -d' ' -f1)
- fi
- #echo save: $save
- #echo backup: $backup
- #echo save_hash: $save_hash
- #echo backup_hash: $backup_hash
- if [[ "$backup_hash" == "$save_hash" ]]; then
- echo -e "${GREEN}$save matches latest backup, no backup needed${NC}"
- else
- cp "$save" "${backupDir}/${save}-${dateString}"
- RET=$?
- if [[ $RET -eq 0 ]]; then
- echo -e "${YELLOW}Copied $save to ${backupDir}/${save}-${dateString}${NC}"
- else
- echo -e "${RED}Error! cp returned $RET for $save${NC}"
- fi
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement