Last active
December 10, 2015 00:28
-
-
Save kaos/4350985 to your computer and use it in GitHub Desktop.
2012/12/21 Alain O'Dea <[email protected]>:
> Brace yourselves for a brain dump :)
> Here is a fairly literal transcript of how I did this for my blog. Some scripts will need path changes, etc. to work on your setup.
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
Create an SSH key: | |
ssh-keygen | |
Create a repository named blog.alainodea.com in Github: | |
Go to Settings | |
Click on Deploy Keys | |
Click on Add Deploy Key | |
Set Title to "zotonic-sync" | |
Set Key to the content of /home/zotonic/.ssh/id_rsa.pub | |
Create /home/zotonic/blog.alainodea.com/.gitignore with the following content: | |
/.idea/ | |
/.idea_modules/ | |
/config | |
/files/backup/ | |
/files/preview/ | |
/files/dropbox/ | |
/files/processing/ | |
/files/unhandled/ | |
.empty | |
.emtpty | |
*~ | |
Set up /home/zotonic/blog.alainodea.com with Git and Github: | |
cd /home/zotonic/blog.alainodea.com | |
git init | |
git add . | |
git commit -m "Initial commit" | |
git remote add origin [email protected]:AlainODea/blog.alainodea.com.git | |
git config branch.master.remote origin | |
Create /etc/cron.hourly/sync-zotonic with the following content: | |
#!/bin/sh | |
su -l zotonic /home/zotonic/bin/sync | |
Make /etc/cron.hourly/sync-zotonic executable: | |
chmod +x /etc/cron.hourly/sync-zotonic | |
Create bin and logs directories: | |
mkdir /home/zotonic/bin | |
mkdir /home/zotonic/logs | |
Create /home/zotonic/bin/sync with the following content: | |
#!/bin/bash | |
~/bin/git_sync >> ~/logs/sync 2>&1 | |
Make /home/zotonic/bin/sync executable: | |
chmod +x /home/zotonic/bin/sync | |
Create /home/zotonic/bin/git_sync with the following content: | |
#!/bin/bash | |
echo "`date`: Started sync" && \ | |
cd ~/blog.alainodea.com/ && \ | |
pg_dump zotonic_blog > zotonic_blog.sql && \ | |
git add --all && \ | |
git commit -m "Content snapshot" | |
git pull origin master && \ | |
git push origin master && \ | |
echo "`date`: Finished sync" | |
Make /home/zotonic/bin/git_sync executable: | |
chmod +x /home/zotonic/bin/git_sync | |
YMMV, but drop me a line if you have trouble :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bear in mind that while my site code is in /home/zotonic/blog.alainodea.com/ it is actually in zotonic as a symlink zotonic/priv/sites/blog. As Kunthar pointed out to me on GTalk it is not supported for the site directory to be an FQDN.