@Bristow-0 I’m working on a fix for this, however it will likley mean you need ot setup and get your api token and user api token.
Basically, my thought is to create an API endpoint that allows you to get the database backup, but securely.
The reason:
All your AD and username secrets are stored in the database, so anyone who can download the database now has all the access credentials to all the data in your environment.
I think you can imagine the repercussions this could cause and I apologize we even had this open wide gap for any period of time.
I want this to continue to work for you, but we need this to be secure too, working on it now:
The issue is documented as well the api endpoint documentation:
https://github.com/FOGProject/fogproject/issues/827
Hope this helps.
Testing this I did:
curl -ik -X GET "https://10.255.20.1/fog/system/export" -H "fog-api-token: $FOG_API" -H "fog-user-token: $FOG_USR" -o 'test_db.sql'
Of course changing the IP to yours and setting your variables where required would make sense.
Your script would be adjusted to:
#!/bin/bash
fogServerAddress="172.X.Y.Z" # Change to actual FOG server address
fogApiToken="YOURFOGAPITOKEN" # Change to FOG Configuration -> Settings -> FOG API Token (ensure api is enabled for global access)
fogUsrToken="YOURFOGUSERAPITOKEN" # Change to User -> API Token (ensure api is enabled for user.)
backupDate=$(date +"%Y%m%d")
backupDir="/mnt/FOGBackups/$backupDate"
backupDirImages="/mnt/FOGBackups/images"
snapinLocation="/opt/fog/snapins"
reportLocation="/var/www/fog/lib/reports"
imageLocation="/images"
failedBackupDB=0
failedBackupSnapins=0
failedBackupReports=0
failedBackupImages=0
[[ ! -d $backupDir ]] && mkdir -p $backupDir/{mysql,snapins,reports,logs} >/dev/null 2>&1
[[ ! -d $backupDir/mysql || $backupDir/snapins || $backupDir/reports || $backupDir/logs ]] && mkdir -p $backupDir/{mysql,snapins,reports,logs} >/dev/null 2>&1
backupDB() {
curl -ik -X GET "http://$fogServer/fog/system/export" -H "fog-api-token: $fogApiToken" -H "fog-user-token: $fogUsrToken" -o $backupDir/mysql/fog.sql 2>>$backupDir/logs/error.log 1>>$backupDir/logs/progress.log 2>&1
stat=$?
if [[ ! $stat -eq 0 ]]; then
echo "Failed to backup database!"
failedBackupDB=1
else
echo "Database backed up."
fi
}
backupSnapins() {
cp -r $snapinLocation $backupDir/snapins/ 2>>$backupDir/logs/error.log 1>>$backupDir/logs/progress.log 2>&1
stat=$?
if [[ ! $stat -eq 0 ]]; then
echo "Failed to backup snapins!"
failedBackupSnapins=1
else
echo "Snapins backed up."
fi
}
backupReports() {
cp -r $reportLocation $backupDir/reports/ 2>>$backupDir/logs/error.log 1>>$backupDir/logs/progress.log 2>&1
stat=$?
if [[ ! $stat -eq 0 ]]; then
echo "Failed to backup reports!"
failedBackupReports=1
else
echo "Reports backed up."
fi
}
backupImages() {
rsync -auv $imageLocation $backupDirImages 2>>$backupDir/logs/error.log 1>>$backupDir/logs/progress.log 2>&1
stat=$?
if [[ ! $stat -eq 0 ]]; then
echo "Failed to backup images!"
failedBackupImages=1
else
echo "Images backed up."
fi
}
checkForFailures() {
echo "Running checkForFailures()"
if [[ $failedBackupDB -eq 1 ]]; then
message="$message \nFailed to backup database."
fi
if [[ $failedBackupSnapins -eq 1 ]]; then
message="$message \nFailed to backup snapins."
fi
if [[ $failedBackupReports -eq 1 ]]; then
message="$message \nFailed to backup reports."
fi
if [[ $failedBackupImages -eq 1 ]]; then
message="$message \nFailed to backup images."
fi
}
sendNotif() {
echo "Running sendNotif()"
if [[ ! -z $message ]]; then
{
curl -d "FOG Backup Failed\n $message" ntfy.sh/XYZATEHFJICH
}
else
curl -d "FOG Backup Successful!" ntfy.sh/XYZATEHFJICH
fi
}
backupDB
backupSnapins
backupReports
backupImages
checkForFailures
sendNotif