Skip to content

Instantly share code, notes, and snippets.

@ijin82
Last active June 21, 2017 15:20
Show Gist options
  • Save ijin82/598f4ecf1a30dd48d14d8b4141dfc11b to your computer and use it in GitHub Desktop.
Save ijin82/598f4ecf1a30dd48d14d8b4141dfc11b to your computer and use it in GitHub Desktop.
backup-folders-list.sh
#!/bin/bash
## config
backupFoldersList="
/home/user/projects/project-name
"
backupDstFolder="/home/user/projects-dump"
## /config
targetFolder="dump-$(date +%Y-%m-%d_%H%M%S)"
backupFolder="$backupDstFolder/$targetFolder/"
echo "
--------------------------------------------------
simple backup
now: "`date`"
i'll save dump to: "$backupFolder"
--------------------------------------------------
"
# create dir for current dump
mkdir -p $backupFolder
echo "dumping folders:
--------------------------------------------------
"
# pack all src dirs
for folder in $backupFoldersList; do
dstFile=$backupFolder`basename $folder`".tar.gz"
echo $folder" -> "$dstFile
tar -czf $dstFile -C $folder ./ &> /dev/null # no output from tar
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment