Advertisement
kerbo_

arma_backup.sh

Feb 12th, 2025
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.65 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Colors
  4. RED="\e[0;91m"
  5. GREEN="\e[0;92m"
  6. YELLOW="\e[0;93m"
  7. NC="\e[0m"
  8.  
  9. #  CHANGE ME
  10. profileName="Kerbo"
  11. armaDir="/opt/games/steam/steamapps/compatdata/107410/pfx/drive_c/users/steamuser/Documents/Arma 3 - Other Profiles/${profileName}"
  12. backupDir="/data/backup/savegames/ArmA 3"
  13.  
  14. dateString=$(date +"%Y-%m-%d_%H-%M")
  15.  
  16. if [[ ! -d "$backupDir" ]]; then
  17.     mkdir "$backupDir"
  18.     if [[ ! -d "$backupDir" ]]; then
  19.         echo "Error creating backup directory: $backupDir"
  20.         exit 1
  21.     fi
  22. fi
  23.  
  24. configs=("$profileName.ArmA3Profile"
  25.     "$profileName.vars.ArmA3Profile"
  26.     "AntistasiCommunity.vars"
  27.     "AntistasiPlus.vars")
  28.  
  29. cd "$armaDir" || exit 1
  30.  
  31. for config in "${configs[@]}"; do
  32.     if [[ -f "$config" ]]; then
  33.         config_hash=$(md5sum "$config" | cut -d' ' -f1)
  34.         backup=$(ls "${backupDir}"/${config}-* 2>/dev/null | tail -n1)
  35.         backup_hash=""
  36.         if [[ -n "$backup" ]]; then
  37.             backup_hash=$(md5sum "$backup" | cut -d' ' -f1)        
  38.         fi
  39.         #echo config: $config
  40.         #echo backup: $backup
  41.         #echo config_hash: $config_hash
  42.         #echo backup_hash: $backup_hash
  43.         if [[ "$backup_hash" == "$config_hash" ]]; then
  44.             echo -e "${GREEN}$config matches latest backup, no backup needed${NC}"
  45.         else
  46.             cp "$config" "${backupDir}/${config}-${dateString}"
  47.             RET=$?
  48.             if [[ $RET -eq 0 ]]; then
  49.                 echo -e "${YELLOW}Copied $config to ${backupDir}/${config}-${dateString}${NC}"
  50.             else
  51.                 echo -e "${RED}Error! cp returned $RET for $config${NC}"
  52.             fi
  53.         fi
  54.     fi
  55. done
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement