From fec9a8391bf363d6082e07dad8f616c81ec5cf34 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 26 Aug 2020 08:37:45 +0200 Subject: [PATCH] add simple backup functions --- home/-shrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/home/-shrc b/home/-shrc index 17f9fbd..aba0f89 100644 --- a/home/-shrc +++ b/home/-shrc @@ -170,6 +170,24 @@ pegg() { pippy "https://github.com/$1/$2/tarball/${3:-master}#egg=$2" } +bak() { + if [ -s "$1.bak" ]; then + bak "$1.bak" + fi + cp -p "$1" "$1.bak" +} + +baks() { # backup, timestamped + local fp="$1" + local now="$(date -u '+%y-%m-%d_%H-%M-%S')" + local bak="$fp.$now.bak" + if [ -s "$bak" ]; then + echo "how in the hell? $bak already exists" >&2 + return + fi + cp -p "$fp" "$bak" +} + # sources {{{1 if [ $FANCY -eq 1 ]; then