Hello, I wonder what kind of site deployment strategies you all use.
I usually have a local git repo, a testingt remote BARE repo and a live BARE repo. On both the testing and live repos I have a post-receive hook which deploys the website to the public folder using checkout -f.
But this has several limitations as far as my experience goes. For example I can’t seem to easily track some files but exclude them from the deployment process.
So… what techniques, tools… do you people use for deploying websites?
Thank you
1 Like
Perry
May 6, 2020, 1:39pm
2
2 Likes
Any reccomendations, caveats or comments on that particular tool ? thank you
hi @plagasul
i’m using this simple bash script for deployment.
#!/bin/bash
# SSH
SSH_LOGIN="kirby@kirby.super.site:"
# URLs
DEV_URL="dev.kirby.super.site"
STAGE_URL="stage.kirby.super.site"
PROD_URL="kirby.super.site"
# Public folder
PUBLIC_FOLDER_LOCAL="../public/"
PUBLIC_FOLDER_DEV="/home/kirby/public_html/$DEV_URL/"
PUBLIC_FOLDER_STAGE="/home/kirby/public_html/$STAGE_URL/"
PUBLIC_FOLDER_PROD="/home/kirby/public_html/$PROD_URL/"
# Code
CODE_FOLDER_LOCAL="../public/"
CODE_FOLDER_DEV="/home/kirby/public_html/$DEV_URL/"
CODE_FOLDER_STAGE="/home/kirby/public_html/$STAGE_URL/"
CODE_FOLDER_PROD="/home/kirby/public_html/$PROD_URL/"
# Accounts folder
ACCOUNTS_FOLDER_LOCAL="../public/site/accounts/"
ACCOUNTS_FOLDER_DEV="/home/kirby/public_html/$DEV_URL/site/accounts/"
ACCOUNTS_FOLDER_STAGE="/home/kirby/public_html/$STAGE_URL/site/accounts/"
ACCOUNTS_FOLDER_PROD="/home/kirby/public_html/$PROD_URL/site/accounts/"
# Content folder
CONTENT_FOLDER_LOCAL="../public/content/"
CONTENT_FOLDER_DEV="/home/kirby/public_html/$DEV_URL/content/"
CONTENT_FOLDER_STAGE="/home/kirby/public_html/$STAGE_URL/content/"
CONTENT_FOLDER_PROD="/home/kirby/public_html/$PROD_URL/content/"
# Public folder
if [[ "$1" == "public:pull:dev" ]]; then
echo "public pull dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$PUBLIC_FOLDER_DEV $PUBLIC_FOLDER_LOCAL
fi
if [[ "$1" == "public:push:dev" ]]; then
echo "public push dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $PUBLIC_FOLDER_LOCAL $SSH_LOGIN$PUBLIC_FOLDER_DEV
fi
if [[ "$1" == "public:pull:stage" ]]; then
echo "public pull stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$PUBLIC_FOLDER_STAGE $PUBLIC_FOLDER_LOCAL
fi
if [[ "$1" == "public:push:stage" ]]; then
echo "public push stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $PUBLIC_FOLDER_LOCAL $SSH_LOGIN$PUBLIC_FOLDER_STAGE
fi
if [[ "$1" == "public:pull:prod" ]]; then
echo "public pull prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$PUBLIC_FOLDER_PROD $PUBLIC_FOLDER_LOCAL
fi
if [[ "$1" == "public:push:prod" ]]; then
echo "public push prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $PUBLIC_FOLDER_LOCAL $SSH_LOGIN$PUBLIC_FOLDER_PROD
fi
# Code
if [[ "$1" == "code:pull:dev" ]]; then
echo "code pull dev!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $SSH_LOGIN$CODE_FOLDER_DEV $CODE_FOLDER_LOCAL
fi
if [[ "$1" == "code:push:dev" ]]; then
echo "code push dev!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $CODE_FOLDER_LOCAL $SSH_LOGIN$CODE_FOLDER_DEV
fi
if [[ "$1" == "code:pull:stage" ]]; then
echo "code pull stage!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $SSH_LOGIN$CODE_FOLDER_STAGE $CODE_FOLDER_LOCAL
fi
if [[ "$1" == "code:push:stage" ]]; then
echo "code push stage!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $CODE_FOLDER_LOCAL $SSH_LOGIN$CODE_FOLDER_STAGE
fi
if [[ "$1" == "code:pull:prod" ]]; then
echo "code pull prod!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $SSH_LOGIN$CODE_FOLDER_PROD $CODE_FOLDER_LOCAL
fi
if [[ "$1" == "code:push:prod" ]]; then
echo "code push prod!"
rsync -az --force --delete --progress --exclude-from=rsync_code_exclude.txt -e "ssh -p22" $CODE_FOLDER_LOCAL $SSH_LOGIN$CODE_FOLDER_PROD
fi
# Accounts folder
if [[ "$1" == "accounts:pull:dev" ]]; then
echo "accounts pull dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$ACCOUNTS_FOLDER_DEV $ACCOUNTS_FOLDER_LOCAL
fi
if [[ "$1" == "accounts:push:dev" ]]; then
echo "accounts push dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $ACCOUNTS_FOLDER_LOCAL $SSH_LOGIN$ACCOUNTS_FOLDER_DEV
fi
if [[ "$1" == "accounts:pull:stage" ]]; then
echo "accounts pull stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$ACCOUNTS_FOLDER_STAGE $ACCOUNTS_FOLDER_LOCAL
fi
if [[ "$1" == "accounts:push:stage" ]]; then
echo "accounts push stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $ACCOUNTS_FOLDER_LOCAL $SSH_LOGIN$ACCOUNTS_FOLDER_STAGE
fi
if [[ "$1" == "accounts:pull:prod" ]]; then
echo "accounts pull prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$ACCOUNTS_FOLDER_PROD $ACCOUNTS_FOLDER_LOCAL
fi
if [[ "$1" == "accounts:push:prod" ]]; then
echo "accounts push prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $ACCOUNTS_FOLDER_LOCAL $SSH_LOGIN$ACCOUNTS_FOLDER_PROD
fi
# Content folder
if [[ "$1" == "content:pull:dev" ]]; then
echo "content pull dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$CONTENT_FOLDER_DEV $CONTENT_FOLDER_LOCAL
fi
if [[ "$1" == "content:push:dev" ]]; then
echo "content push dev!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $CONTENT_FOLDER_LOCAL $SSH_LOGIN$CONTENT_FOLDER_DEV
fi
if [[ "$1" == "content:pull:stage" ]]; then
echo "content pull stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$CONTENT_FOLDER_STAGE $CONTENT_FOLDER_LOCAL
fi
if [[ "$1" == "content:push:stage" ]]; then
echo "content push stage!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $CONTENT_FOLDER_LOCAL $SSH_LOGIN$CONTENT_FOLDER_STAGE
fi
if [[ "$1" == "content:pull:prod" ]]; then
echo "content pull prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $SSH_LOGIN$CONTENT_FOLDER_PROD $CONTENT_FOLDER_LOCAL
fi
if [[ "$1" == "content:push:prod" ]]; then
echo "content push prod!"
rsync -az --force --delete --progress --exclude-from=rsync_exclude.txt -e "ssh -p22" $CONTENT_FOLDER_LOCAL $SSH_LOGIN$CONTENT_FOLDER_PROD
fi
Saludos, Funkybrotha
2 Likes
hey @plagasul
i forgot these important files:
rsync_code_exclude.txt
.git
.gitignore
.DS_Store
accounts/
content/
rsync_exclude.txt
.git
.gitignore
.DS_Store
1 Like
Peleke
December 17, 2021, 2:18pm
7
If I want to combine --delete with --exclude and make sure that also deleted files/folders of the source/development environment get deleted I cannot make it to work with --delete-exlcuded and the content folder.
How do you use rsync to make sure that no further required files/folders pile up in the target directory while still making sure that the content folder survives?
rsync --checksum --stats --info=progress2 -ha --delete --delete-excluded --exclude-from=.rsync-exclude ./ ../