Bash Shell Current Date Minus Number of Days

You can use the following script:

#!/bin/bash
days=73
while [ ${days} -ge 0 ]; do
    date -d "${days} days ago" +'%F'
    days=$((days-1))
done

Try doing this :

#!/bin/sh
#
# BACKUP DB TO S3
#

# VARIABLES
TYPE="DATABASE"
DAYS="30"

# GET CURRENT DATETIME
CURRENTDATE="$(date +%Y%m%d%H%M%S)"

# GENERATE PAST DATE FROM DAYS CONSTANT
OLDERDATE="$(date "+%Y%m%d%H%M%S" -d "$DAYS days ago")"

# CALL PYTHON SCRIPT WITH OLDERDATE ARGUMENT
python script.py "$OLDERDATE"

See info coreutils 'date invocation' | less +/28.7\ Relative\ items\ in\ date\ strings


Try

date -d '30 days ago'

should do on debian.