Skip to content

Instantly share code, notes, and snippets.

@tjirab
Last active December 4, 2017 10:26
Show Gist options
  • Save tjirab/7d21d6e0522df0806c936acfad1840a5 to your computer and use it in GitHub Desktop.
Save tjirab/7d21d6e0522df0806c936acfad1840a5 to your computer and use it in GitHub Desktop.
# Parameters
FILES="file1 file2 file3 file4"
CURDATE=$(date +%Y%m%d)
SOURCE="/foo/bar/"
# Move files from eout to user dir
for FILE in $FILES; do
mv ${SOURCE}/${FILE} ${FILE}
done
# tar all files
tar -cf backup_${CURDATE}.tar $(echo ${FILES})
# Compress tar
gzip backup_${CURDATE}.tar
# Remove all ordinary files that are not .tar.gz
find . -type f ! -name '*.tar.gz' -delete
# Decompress
gunzip <file>
# View files in tar
tar -tvf <tar>
# Unpack
tar -xf <tar>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment