Skip to content

Instantly share code, notes, and snippets.

@gjpalau
Created May 14, 2015 00:07
Show Gist options
  • Save gjpalau/fee07e9f0e6eb0b42371 to your computer and use it in GitHub Desktop.
Save gjpalau/fee07e9f0e6eb0b42371 to your computer and use it in GitHub Desktop.
Rsync Capture
# !/bin/bash
# RSYNC Capture
# Carlos Raygada / Gilbert Palau
# May 2015 v.01
#Stores Mac Serial Number in $serial
serial=$(ioreg -l |grep "IOPlatformSerialNumber"|cut -d ""="" -f 2|sed -e s/[^[:alnum:]]//g)
#Stores Username
echo enter username:
read username
#Stores service account username in a variable called $svcAcct
echo enter service account to use:
read svcAcct
#Stores password in a variable called $password
echo enter the password for this account:
read -s password
# Make DMG
/usr/bin/hdiutil create -puppetstrings -ov -fs HFS+ -srcFolder "/Users/$username/" -volname "$serial" "/Users/$username/dmg_temp/$username.dmg"
#creates the directory to mount the remote file system to
mkdir /Volumes/backups
#mounts the file system and automatically enters the password without prompting
echo $password | mount_smbfs "//qualified.domain.name;$svcAcct@nas/location/_Mac_User_Backups" /Volumes/backups
#traverses to the /temp/temp-mac-collection-space folder and creates a folder with the user's name
cd /Volumes/backups/
mkdir "$serial"
#copies the files to the remote system
rsync --rsync-path='/usr/bin/sudo /usr/bin/rsync' -arv "/Users/$username/dmg_temp/" "./$serial"
#leaves the directory and unmounts the remote system.
cd /
umount /Volumes/backups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment