Last active
October 24, 2022 06:05
-
-
Save ibrezm1/64c189168bfd2ae859f1a52d5ce42060 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
# 341 vi ~/.profile | |
# 342 ssh-copy-id [email protected] | |
# 344 source ~/.profile | |
# 343 pls | |
# Usage | |
# Backup current folder ( will exclude . files ) | |
# pbkp | |
# List remote | |
# $ pls | |
# Get Remote ( project without tar ) | |
# $ prcv PyScript-test | |
sev='[email protected]' | |
tloc='/home/pi/pyshuploads/' | |
pbkp() { | |
bname=$(basename $(pwd) ) | |
read -r -p "Are you sure to backup $bname? [y/N] " response | |
case "$response" in | |
[yY][eE][sS]|[yY]) | |
rm /tmp/$bname.tar | |
find . -type f ! -path "./tvenv/*" ! -path "./node*" ! -path '*/.*' -exec tar -rvf /tmp/$bname.tar "{}" \; \ | |
&& scp /tmp/$bname.tar $sev:$tloc$bname.tar | |
#ssh [email protected] "echo '$bname $@' >> /g.txt" | |
;; | |
*) | |
echo "Not executing backup .. skippping" | |
;; | |
esac | |
} | |
prcv() { | |
proj=$(ssh $sev ls -l $tloc*.tar | grep $1.tar | wc -l) | |
if [[ "$proj" -eq 1 ]]; then | |
scp $sev:$tloc$1.tar /tmp/$1.tar && mkdir ./$1 && tar -xf /tmp/$1.tar -C ./$1/ | |
else | |
echo "Project $1.tar not found in remote repo" | |
fi | |
} | |
pls() { | |
ssh $sev ls -l $tloc*.tar | |
} | |
pssh() { | |
ssh $sev | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment