Created
September 1, 2021 08:06
-
-
Save mao-odoo/15ea4735eb0ae3230fee09ea0c762c56 to your computer and use it in GitHub Desktop.
send filestore to odoo.sh in smaller, compressed parts
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
sync_filestore_to_remote() { | |
# sends a local filestore to a remote server in batches (1 per filestore folder) | |
# the goal is too use less additional space than a big zip file, while not sending | |
# each file individually (which might trigger a network rate limiting) | |
args=("$@") | |
ELEMENTS=${#args[@]} | |
if [ $ELEMENTS -ne 3 ]; then | |
echo "Usage: sync_filestore_to_remote local_filestore_path remote_host remote_filestore_path" | |
exit 1 | |
fi | |
local local_filestore_path=$1 | |
local remote_host=$2 | |
local remote_filestore_path=$3 | |
cd $local_filestore_path | |
for folder in $(ls); do | |
echo "starting work on $folder ------------------------------" | |
zip -r "tmp$folder.zip" $folder/* | |
echo "finishing zip folder" | |
echo "sending °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°" | |
rsync -rhP "tmp$folder.zip" "$remote_host:$remote_filestore_path" | |
echo "finished sending °°°°°°°°°°°°°°°°°°°°°°°°°°°°°" | |
echo "starting remote commande ##############################" | |
ssh $remote_host "cd $remote_filestore_path; unzip -u tmp$folder.zip; rm tmp$folder.zip" | |
echo "$folder done ------------------------------------------" | |
rm "tmp$folder.zip" | |
echo "sleeping 5 seconds to avoid rate limiting on odoosh ..." | |
sleep 5 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment