#!/bin/bash
HOST=""
USER=""
PASSWD=""
UFILE="/bk"
DAYS=2
MONTHS=3
LIST="$(curl -u $USER:$PASSWD ftp://$HOST/$UFILE/ -s -l)"
for li in $LIST
do
EXIST=0
if [ "$li" = "." ] || [ "$li" = ".." ]
then
continue
fi
for day in `seq 0 $DAYS`
do
d="$(date +%Y-%m-%d -d "$day days ago")"
if [[ $li =~ backups_all_$d|.*.tar.gz ]]; then
echo days, file name - $li
EXIST=1
continue
fi
done
for month in `seq 0 $MONTHS`
do
d="$(date +%Y-%m-01 -d "$month month ago")"
if [[ $li =~ backups_all_$d|.*.tar.gz ]]; then
echo days, file name - $li
EXIST=1
continue
fi
done
if [ $EXIST -eq 0 ]
then
echo Del, file name - $li, EXIST - $EXIST
# curl -u $USER:$PASSWD ftp://$HOST/$UFILE/ -s -X "DELE $li"
fi
done
bash script.sh
days, file name - backups_all_2021-01-10|11-29-47.tar.gz
days, file name - backups_all_2021-01-10|11-29-47.tar.gz
days, file name - backups_all_2021-01-10|11-29-47.tar.gz
monts, file name - backups_all_2021-01-10|11-29-47.tar.gz
monts, file name - backups_all_2021-01-10|11-29-47.tar.gz
monts, file name - backups_all_2021-01-10|11-29-47.tar.gz
monts, file name - backups_all_2021-01-10|11-29-47.tar.gz
days, file name - backups_all_2021-01-09|11-29-47.tar.gz
days, file name - backups_all_2021-01-09|11-29-47.tar.gz
days, file name - backups_all_2021-01-09|11-29-47.tar.gz
monts, file name - backups_all_2021-01-09|11-29-47.tar.gz
monts, file name - backups_all_2021-01-09|11-29-47.tar.gz
monts, file name - backups_all_2021-01-09|11-29-47.tar.gz
monts, file name - backups_all_2021-01-09|11-29-47.tar.gz
days, file name - backups_all_2021-01-08|11-29-47.tar.gz
days, file name - backups_all_2021-01-08|11-29-47.tar.gz
days, file name - backups_all_2021-01-08|11-29-47.tar.gz
monts, file name - backups_all_2021-01-08|11-29-47.tar.gz
monts, file name - backups_all_2021-01-08|11-29-47.tar.gz
monts, file name - backups_all_2021-01-08|11-29-47.tar.gz
monts, file name - backups_all_2021-01-08|11-29-47.tar.gz
days, file name - backups_all_2021-01-07|11-29-47.tar.gz
days, file name - backups_all_2021-01-07|11-29-47.tar.gz
days, file name - backups_all_2021-01-07|11-29-47.tar.gz
monts, file name - backups_all_2021-01-07|11-29-47.tar.gz
monts, file name - backups_all_2021-01-07|11-29-47.tar.gz
monts, file name - backups_all_2021-01-07|11-29-47.tar.gz
monts, file name - backups_all_2021-01-07|11-29-47.tar.gz
days, file name - backups_all_2021-01-06|11-29-47.tar.gz
days, file name - backups_all_2021-01-06|11-29-47.tar.gz
days, file name - backups_all_2021-01-06|11-29-47.tar.gz
monts, file name - backups_all_2021-01-06|11-29-47.tar.gz
monts, file name - backups_all_2021-01-06|11-29-47.tar.gz
monts, file name - backups_all_2021-01-06|11-29-47.tar.gz
monts, file name - backups_all_2021-01-06|11-29-47.tar.gz
days, file name - test.tar.gz
days, file name - test.tar.gz
days, file name - test.tar.gz
monts, file name - test.tar.gz
monts, file name - test.tar.gz
monts, file name - test.tar.gz
monts, file name - test.tar.gz
backups_all_2021-01-06|11-29-47.tar.gz
backups_all_2021-01-07|11-29-47.tar.gz
backups_all_2021-01-08|11-29-47.tar.gz
backups_all_2021-01-09|11-29-47.tar.gz
backups_all_2021-01-10|11-29-47.tar.gz
test.tar.gz
backups_all_2021-01-06|11-29-47.tar.gz
backups_all_2021-01-07|11-29-47.tar.gz
backups_all_2021-01-08|11-29-47.tar.gz
test.tar.gz
#!/bin/bash
HOST=""
USER=""
PASSWD=""
UFILE="/bk"
DAYS=3
MONTHS=3
LIST="$(curl -u $USER:$PASSWD ftp://$HOST/$UFILE/ -s -l)"
for li in $LIST
do
EXIST=0
if [ "$li" = "." ] || [ "$li" = ".." ]
then
continue
fi
for day in `seq 0 $DAYS`
do
d="$(date +%Y-%m-%d -d "$day days ago")"
if [[ $li =~ backups_all_$d|.*.tar.gz ]]; then
EXIST=1
continue
fi
done
for month in `seq 0 $MONTHS`
do
d="$(date +%Y-%m-01 -d "$month month ago")"
if [[ $li =~ backups_all_$d|.*.tar.gz ]]; then
EXIST=1
continue
fi
done
if [ $EXIST -eq 0 ]
then
curl -u $USER:$PASSWD ftp://$HOST/$UFILE/ -s -X "DELE $li"
fi
done
test_del.sh: 23: test_del.sh: [[: not found
test_del.sh: 23: test_del.sh: .*.tar.gz: not found
test_del.sh: 32: test_del.sh: [[: not found
test_del.sh: 32: test_del.sh: .*.tar.gz: not found
ip rule add from $(ip route get 1 | grep -Po '(?<=src )(\S+)') table 128
ip route add table 128 to $(ip route get 1 | grep -Po '(?<=src )(\S+)')/32 dev $(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
ip route add table 128 default via $(ip -4 route ls | grep default | grep -Po '(?<=via )(\S+)')
openvpn --pull-filter ignore "route ${ip_PS}" --config /etc/openvpn/client1.ovpn
openvpn --pull-filter ignore redirect-gateway --config /etc/openvpn/client1.ovpn