Skip to content

Instantly share code, notes, and snippets.

@jarun jarun/Backup
Created Nov 28, 2014

Embed
What would you like to do?
Backup modified files
$ cat list.txt
/home/arun/.bashrc
/home/arun/.vimrc
/home/arun/.config/smplayer/smplayer.ini
/opt/tor-browser_en-US/Docs/ChangeLog.txt
$ take_backup.sh list.txt
$ tar -xvf backup-timestamp.tar.bz2 -C /
-------------------------------------------------
#!/bin/bash
#file: take_backup.sh
lt_red='\e[1;31m'
BACKUP_DIR=backup-$(date "+%Y_%m_%d_%H_%M_%S")
mkdir $BACKUP_DIR
cat $1 | xargs cp --parents -t $BACKUP_DIR
cd $BACKUP_DIR
tar -jcvf ../$BACKUP_DIR.tar.bz2 *
cd ..
rm -rf $BACKUP_DIR
echo -e ${lt_red}Backed-up in $BACKUP_DIR.tar.bz2
-------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.