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
- profileName="Kerbo"
- armaDir="/opt/games/steam/steamapps/compatdata/107410/pfx/drive_c/users/steamuser/Documents/Arma 3 - Other Profiles/${profileName}"
- backupDir="/data/backup/savegames/ArmA 3"
- 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
- configs=("$profileName.ArmA3Profile"
- "$profileName.vars.ArmA3Profile"
- "AntistasiCommunity.vars"
- "AntistasiPlus.vars")
- cd "$armaDir" || exit 1
- for config in "${configs[@]}"; do
- if [[ -f "$config" ]]; then
- config_hash=$(md5sum "$config" | cut -d' ' -f1)
- backup=$(ls "${backupDir}"/${config}-* 2>/dev/null | tail -n1)
- backup_hash=""
- if [[ -n "$backup" ]]; then
- backup_hash=$(md5sum "$backup" | cut -d' ' -f1)
- fi
- #echo config: $config
- #echo backup: $backup
- #echo config_hash: $config_hash
- #echo backup_hash: $backup_hash
- if [[ "$backup_hash" == "$config_hash" ]]; then
- echo -e "${GREEN}$config matches latest backup, no backup needed${NC}"
- else
- cp "$config" "${backupDir}/${config}-${dateString}"
- RET=$?
- if [[ $RET -eq 0 ]]; then
- echo -e "${YELLOW}Copied $config to ${backupDir}/${config}-${dateString}${NC}"
- else
- echo -e "${RED}Error! cp returned $RET for $config${NC}"
- fi
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement