Skip to content

Instantly share code, notes, and snippets.

@karl-gustav
Created November 13, 2022 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karl-gustav/3c81feb3208473c8c68d595f8b9c9863 to your computer and use it in GitHub Desktop.
Save karl-gustav/3c81feb3208473c8c68d595f8b9c9863 to your computer and use it in GitHub Desktop.
Backup script with aes-256-cbc encryption and automatically spits the output into 4GB chunks (for fat32 file systems)
#! /bin/bash
if ! [ $# -eq 1 ] ;then
echo "Ha mappen du vil ha backup av som argument"
exit 1
fi
echo "Navn på backupen:"
read name
echo "Passord:"
read pass
folder=$1
org_size=`du -bs $folder |cut -f1`
echo "Størrelse i byte: "$org_size
date=`date +%Y.%m.%d`
echo "Starter:"
tar cf - "$folder" |pv -cN Filer -s $org_size |gzip - |openssl aes-256-cbc -pass pass:"$pass" |split -a3 -b 4000m - "$date-$name.tgz.aes-256-cbc-"
md5sum "$date-$name.tgz.aes-256-cbc-"* > "$date-$name.tgz.aes-256-cbc.md5"
@karl-gustav
Copy link
Author

Same thing as a single command:

dir=/media/1TB/bilder/ && echo "Navn på backupen:" && read name && dato=`date +%Y.%m.%d` && tar cf - "$dir" 2>/dev/zero|pv -WcN Filer -s `du -bs "$dir" |cut -f1` |gzip - |openssl aes-256-cbc -kfile pa|split -a3 -b 4000m - "$dato-$name.tgz.aes-256-cbc-" && md5sum "$dato-$name.tgz.aes-256-cbc-*" > "$dato-$name.tgz.aes-256-cbc.md5"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment