Bender - Automated Backup of OS X Server Settings

Follow

Comments

7 comments

  • Ben Greiner

    Recent feedback received:

    I had problems with ProfileManager and fixed it by adding 

    sudo -u _devicemgr

    in front of

    /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_dump -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 -c -f "$backupDestination"/ProfileManager/device_management-$host-$date.sql

    If I change backupDestination="/Backups/$date" I also have to change:

    find "$pathBackups/Backups" -mtime +$keepUntil -maxdepth 1 -exec rm -rf {} \;

    For Calendar backup I added:

    function CalendarBackup () {
    # Ensure the backup directory is present and assign the path as a variable.
    /bin/mkdir -p "$backupDestination"/Calendar
    # Create a backup of profilemanager database.
    /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_dump -h /var/run/caldavd/PostgresSocket/ --username=caldav caldav -f "$backupDestination"/Calendar/caldav-$host-$date.sql
    if [ $? == 0 ]; then
    LogEvent "[ backup ] Calendar successfully backed up."
    else
    LogEvent "[ error ] Could not back up Calendar. Exit Code: $?"
    fi
    }
  • Ishai Beit Halachmi

    Hi Ben,

    Thanks for the tip using 'sudo -u _devicemgr' 

    We are now able to backup profile manager successfully

    However - we are unable to restore - we get sql error - 

    psql: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/Library/Server/ProfileManager/Config/var/PostgreSQL/.s.PGSQL.5432

    Running macOS Sierra 10.12.6 with Server 5.3.1 

    Have you seen this error before ?

    Thanks

     

  • Ben Greiner

    Hi Ishai, Did you try the note mentioned above about restoring Profile Manager in 10.12?

  • Ishai Beit Halachmi

    Hi Ben - which mention would that be ? This one ?

    To restore Profile Manager:

    sudo cat /path/to/your-profile-backup.sql | psql -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 

     

  • Ben Greiner

    Ishai, you mentioned running 10.12 so I believe this is the one you want ...

    To restore Profile Manager in macOS Sierra 10.12.3 and Server.app 5.2: (Thanks to Paul Roomberg for figuring this out!)

    sudo pg_restore <path to .pgdump file> -U _devicemgr

     

  • Ishai Beit Halachmi

    Thanks Ben,

    I have probably missed out on this one but this one is for Server.app 5.2 and when trying to restore i get this 

    pg_restore: [archiver] input file appears to be a text format dump. Please use psql

    I understand this is probably a change in Server.app =>5.3 (Also the pg_dump issue you managed to resolve) 

    I will try to get to the bottom of this cause losing our PM database without a way to restore it easily is a major issue 

    Thanks again !

  • Ben Greiner

    Hi Ishai, Did you have any luck finding a way to restore?

Please sign in to leave a comment.