Created
March 20, 2015 02:03
-
-
Save rxw1/da49957779b2b3e5adf8 to your computer and use it in GitHub Desktop.
Colorful backups
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
#!/usr/local/bin/zsh -e | |
# Fri Mar 20 03:01:41 CET 2015 | |
# [email protected] (c) MMXV | |
zmodload -F zsh/stat b:zstat | |
test `which lolcat` && alias -g RAINBOW="|lolcat" || alias -g RAINBOW="" | |
test ! $BACKUPDIR && BACKUPDIR=backups | |
echo -e "\e[1;37mcreating backups ...\e[0m" | |
for f in $@; do | |
backupdir=$BACKUPDIR/`zstat -F '%Y/%m/%d' +mtime -- $f` | |
backupfile=$backupdir/$f.`date +%Y%m%d`.tar.bz | |
test -d $backupdir || mkdir -p $backupdir | |
tar cjpf $backupfile $f && du -k $backupdir/*(.om[1]) | awk '{printf "%10s %s\n", $1, $2}' RAINBOW | |
done && echo done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment