#!/usr/bin/env bash # —————————————————————————– # # File: back.sh # Description: copies given file into dropbox dir with timestamp appended # Author: j kepler github.com/mare-imbrium/canis/ # Date: 2019-01-18 - 12:23 # License: MIT # Last update: 2019-02-23 10:13 # —————————————————————————– # # YFF Copyright (C) 2012-2018 j kepler errecho(){ >&2 echo $@; }
if [ $# -eq 0 ]; then
errecho "Give a file name to copy into dropbox dir" exit 1
fi TODAY=$(date +“%Y%m%d%H%M”) if [[ ! -d back ]]; then
#mkdir back
fi BASE=~/Dropbox/backups YEAR=$(date +“%Y”) TARGET=${BASE}/${YEAR} if [[ ! -d $TARGET ]]; then
mkdir -p $TARGET
fi
cp -p “$1” ${TARGET}/${1}.${TODAY} ls -l ${TARGET}/$1.${TODAY}