Last active
October 16, 2016 20:39
-
-
Save Dineshs91/ea1cb572eac2fbc28dff459346456e9c to your computer and use it in GitHub Desktop.
Backup scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Restoring with tar from a compressed archive. | |
### Test the command first with 't' argument | |
tar -ztvpf /archive/full-backup-02-March-2016.tar.gz | |
### Extract with 'x' argument | |
tar -zxvpf /archive/full-backup-02-March-2016.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# For restoration use, | |
# tar -zxvpf /archive/backup-xx-Oct-xxxx.tar.gz etc/profile | |
# | |
# Only etc/profile is restored. Don't mention anything | |
# to restore completely. | |
dev_dir='/Users/dinesh/Documents/developer' | |
my_dir='/Users/dinesh/Documents/my' | |
ext_hard_disk_dir="/Volumes/vault/backup/full-backup-`date '+%d-%B-%Y'`.tar.gz" | |
echo "Backing up data" | |
echo "$dev_dir $my_dir" | |
echo "Dest directory $ext_hard_disk_dir" | |
time tar -cf "$ext_hard_disk_dir" \ | |
--directory / \ | |
--exclude='node_modules' \ | |
--exclude='bower_components' \ | |
--exclude='source_code' \ | |
--exclude='utilities' \ | |
--exclude='.git' --exclude='venv' \ | |
--exclude='backup-and-restore' \ | |
"$dev_dir" | |
exit_status=$? | |
echo "" | |
if [ $exit_status -eq 0 ];then | |
echo ">>>> Backup completed succesfully <<<<" | |
else | |
echo ">>>> Backup failed <<<<" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN | |
http://www.apple.com/DTDs/PropertyList-1.0.dtd > | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>custom.sync</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/bash</string> | |
<string>/Path/to/sync.sh</string> | |
</array> | |
<key>KeepAlive</key> | |
<true/> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>StandardErrorPath</key> | |
<string>/Users/dinesh/logs/custom-sync.txt</string> | |
</dict> | |
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# This script syncs directories with google drive. | |
my_dir='/Users/dinesh/Documents/my' | |
dest_dir='/Users/dinesh/Google Drive/' | |
# Directories will be synced when any changes are detected | |
# to the directories being watched. | |
/usr/local/bin/fswatch -o "$my_dir" \ | |
| while read | |
do | |
rsync -a --delete "$my_dir" "$dest_dir" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commands to start with
launchctl
.