Last active
May 26, 2020 08:41
-
-
Save athlona64/7002f2173bc5e4e0541cd69ecdbd2f91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| now="$(date +'%d%m%Y')" | |
| echo "Starting backup..." | |
| #/snap/bin/gsutil cp -r gs://backup-newlikewallet/"$now" ./backup | |
| DATE="$(date --date="-15 day" "+%s")" | |
| echo $DATE | |
| echo "successfully backup !" | |
| list=`cd backup && ls` | |
| echo "$list" | |
| for f in $list | |
| do | |
| y=${f:4:4} | |
| echo $y | |
| m=${f:2:2} | |
| echo $m | |
| d=${f:0:2} | |
| createDate="$(date -d "$y-$m-$d" "+%s")" | |
| echo $createDate | |
| if [[ "$createDate" < "$DATE" ]]; then | |
| echo "yes, starting remove $f" | |
| remove=`rm -r ./backup/$f` | |
| echo "remove $f succesfully" | |
| fi | |
| done | |
| echo "Successfully backup !" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment