You are not logged in.

Announcement

[2017.09.08] DeployStudio build v1.7.8 (checksum, release note).
[2016.08.26] DeployStudio build v1.6.19 (release note).
[2013.02.23] DeployStudio last universal build v1.5.17 (release note).

#1 2013-03-12 22:42:01

Grenadier_Teg
Member
Registered: 2013-03-12

Option to backup user Home Directory to DMG

It would be really handy to have an option you could add in to a workflow to create a DMG of a users home directory, upload to server repository and an option to pull back down to machine during deployment.
I work in a school and having students come in with problems, most of the time it is easier to re-image the machine, so having something that would backup the users files at the same time would be incredibly useful.

Offline

#2 2013-07-03 07:47:50

psychozz
Member
From: Kalmar, Sweden
Registered: 2009-02-11
Website

Re: Option to backup user Home Directory to DMG

I actually made a quick and dirty script for this a long time ago. It has no error checking and bugs may appear, but at least you have something to work on :) Haven't tested it since I made it, so make sure you test it and add some error checking before you use it in production.

#!/bin/sh

target=`mount | grep hfs | grep disk0 | cut -c 17- | cut -d "(" -f1 | sed s/.$//`
bk_dir="UserBackups"
exclude="user1 user2 user3"
userdir="$target/Users"

# Folder size in MB
usersize=$(du -sm "$target/Users" | awk '{ print $1 }')

# Disk available
freedisk=$(df -m "$target" | awk '{ print $4 }' | grep -v Available)

# Backing up users locally and then moving it to remote location
function backuplocal {
echo "Backing up locally and then moving the disk image to the repository"
hdiutil create "$target/${DS_COMPUTERNAME}.dmg" -srcdir "$target/Users" -format UDZO
cp "$target/${DS_COMPUTERNAME}.dmg" "${DS_REPOSITORY_PATH}/$bk_dir/${DS_COMPUTERNAME}.dmg"
rm -v "$target/${DS_COMPUTERNAME}.dmg"
}

# Backing up users to remote location
function backupremote {
echo "Backing up /Users directory to repository directly"
hdiutil create "${DS_REPOSITORY_PATH}/$bk_dir/${DS_COMPUTERNAME}.dmg" -srcdir "$target/Users" -format UDZO
}

# deletes excluded accounts
for uname in ${exclude[@]}
do
if [ -e "$target/$userdir/$uname" ]; then
    echo "Deleting homedir for $uname"
    rm -dvR "$target/$userdir/$uname"
fi
done

# if another image exists with the same name then delete
echo "If another image with the same name then delete"
if [ -e "${DS_REPOSITORY_PATH}/$bk_dir/${DS_COMPUTERNAME}.dmg" ]; then
    echo "Found existing image (${DS_REPOSITORY_PATH}/$bk_dir/${DS_COMPUTERNAME}.dmg). Deleting"
    rm -v "${DS_REPOSITORY_PATH}/$bk_dir/${DS_COMPUTERNAME}.dmg"
fi

# Checks if the local disk has enough room for a user backup
if [ $usersize -lt $freedisk ]; then
    echo "Free disk space is enough to backup users locally"
    backuplocal
    else
        echo "Not enough disk space on local disk, backing up to remote location. May take a while..."
        backupremote
fi


exit 0

Offline

#3 2013-09-16 10:09:35

soha
Member
Registered: 2013-09-16

Re: Option to backup user Home Directory to DMG

I found a workaround by downloading the install mac os x.app from appstore that will come with the latest version 10.8.4 in this case. Reinstalled the os through this and it updates the recovery partition to 10.8.4 and then the netboots worked. Obviously this takes about an hour anytime their is a new os x build which sucks, but least its workable.


soha

Offline

Board footer

Powered by FluxBB