Sort files into folders by extension

cd /path/to/dir

shopt -s nullglob
for file in *.{avi,rmvb,mkv}
do
  directory="${file%.*}"             # remove file extension 
  directory="${directory//_/ }"      # replace underscores with spaces

  darr=( $directory )
  darr="${darr[@]^}"                 # capitalize the directory name

  echo mkdir -p -- "$darr"           # create the directory; 
  echo mv -b -- "$file" "$darr"      # move the file to the directory
  echo
done

 

Duplicity bash script to restore data from S3

Restore your S3 duplicity backup

#!/bin/bash

if [ $# -lt 3 ] || [ $# -gt 3 ]; then
        echo 'invalid number of parameters passed'
        echo 'Usage: s3-restore <bucket-name> <folder-name> <output-folder>'
else
        echo 'restoring backup'
        export PASSPHRASE=your_passphrase
        export AWS_ACCESS_KEY_ID=your_aws_access_key
        export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key

        duplicity s3://s3.amazonaws.com/$1/$2 $3
fi

 

Backup to S3 using duplicity

Backup a directory to S3. The script make full backups every 30 days and incremental backups the rest of the time.

#!/bin/bash

if [ $# -lt 3] || [ $# -gt 3]; then
    echo 'invalid number of parameters'
    echo 'Usage: backup <folder-to-backup> <bucket-name> <folder-name>'
else
    echo 'starting backup'
    export PASSPHRASE=your_passphrase
    export AWS_ACCESS_KEY_ID=your_aws_access_key
    export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key

    duplicity --extra-clean --full-if-older-than 1M $1 s3://s3.amazonaws.com/$1/$2
fi