From 81d1cb4f38a12b27b92fcccf182c3e4fd05c9271 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Sun, 13 Jun 2021 22:48:53 +0100 Subject: Add Backing Up a Git Repository --- gemini/index.gmi | 1 + .../backing-up-a-git-repository/index.gmi | 53 ++++++++++++++++++++++ gemini/posts/git/index.gmi | 1 + gemini/posts/index.gmi | 4 ++ www/index.html | 2 +- www/posts/atom.xml | 26 ++++++++++- .../backing-up-a-git-repository/index.html | 41 +++++++++++++++++ www/posts/git/atom.xml | 26 ++++++++++- www/posts/git/index.html | 2 +- www/posts/index.html | 2 +- www/sitemap.xml | 4 ++ 11 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 gemini/posts/git/2021-06-13/backing-up-a-git-repository/index.gmi create mode 100644 www/posts/git/2021-06-13/backing-up-a-git-repository/index.html diff --git a/gemini/index.gmi b/gemini/index.gmi index ee414d1..63d3a88 100644 --- a/gemini/index.gmi +++ b/gemini/index.gmi @@ -4,6 +4,7 @@ Hello and welcome to my little bit of the internet where I occasionally write ab ## Latest Posts +=> /posts/git/2021-06-13/backing-up-a-git-repository/ 2021-06-13 - Backing Up a Git Repository => /posts/linux/2021-06-05/xrandr-failed-to-get-size-of-gamma-for-output-default/ 2021-06-05 - Xrandr: Failed to Get Size of Gamma for Output Default => /posts/git/2021-05-29/setting-up-a-self-host-git-server/ 2021-05-29 - Setting up a Self Hosted Git Server => /posts/letsencrypt/2021-05-28/pre-and-post-validation-hooks-with-certbot/ 2021-05-28 - Pre and Post Validation Hooks with Certbot diff --git a/gemini/posts/git/2021-06-13/backing-up-a-git-repository/index.gmi b/gemini/posts/git/2021-06-13/backing-up-a-git-repository/index.gmi new file mode 100644 index 0000000..6d0a54b --- /dev/null +++ b/gemini/posts/git/2021-06-13/backing-up-a-git-repository/index.gmi @@ -0,0 +1,53 @@ +# Backing Up a Git Repository + +> Sun 13th June 2021 By David T. Sadler. + +Below is a quick and dirty way in which I backup all my repositories that are hosted at git.davidtsadler.com. + +```shell +#!/bin/sh + +DATE_PREFIX=$(date +%Y%m%d) + +BACKUP_DIRECTORY=/tmp + +BACKUP_FILE="${BACKUP_DIRECTORY}/${DATE_PREFIX}-repositories.tar.gz" + +BACKUP_FILES="${BACKUP_DIRECTORY}/*-repositories.tar.gz" + +REPOSITORIES=/home/git/*.git + +tar -czf $BACKUP_FILE $REPOSITORIES + +find $BACKUP_FILES -mtime +3 -delete + +exit 0 +``` + +All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old. + +This script has been saved as /usr/bin/backup_repositories and is ran daily via cron. + +```cron +0 3 * * * /usr/bin/backup_repositories > /dev/null 2>&1 +``` + +It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running. + +### Links + +=> /posts/git/2021-05-29/setting-up-a-self-host-git-server/ 2021-05-29 - Setting up a Self Hosted Git Server + +=> /posts/git/ Git - Read More Posts. + +I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to. + +=> mailto:david@davidtsadler.com Email david@davidtsadler.com + +### License + +=> https://creativecommons.org/licenses/by-sa/4.0/ The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. + +Copyright © 2021 David T. Sadler. + +=> / Return to Homepage. diff --git a/gemini/posts/git/index.gmi b/gemini/posts/git/index.gmi index 67bc17d..c19ecd7 100644 --- a/gemini/posts/git/index.gmi +++ b/gemini/posts/git/index.gmi @@ -1,5 +1,6 @@ # The Home of David T. Sadler - All Posts About Git +=> /posts/git/2021-06-13/backing-up-a-git-repository/ 2021-06-13 - Backing Up a Git Repository => /posts/git/2021-05-29/setting-up-a-self-host-git-server/ 2021-05-29 - Setting up a Self Hosted Git Server ### License diff --git a/gemini/posts/index.gmi b/gemini/posts/index.gmi index 6c7b683..7667661 100644 --- a/gemini/posts/index.gmi +++ b/gemini/posts/index.gmi @@ -1,5 +1,9 @@ # The Home of David T. Sadler - All Posts +=> /posts/git/2021-06-13/backing-up-a-git-repository/ 2021-06-13 - Backing Up a Git Repository +=> /posts/linux/2021-06-05/xrandr-failed-to-get-size-of-gamma-for-output-default/ 2021-06-05 - Xrandr: Failed to Get Size of Gamma for Output Default +=> /posts/git/2021-05-29/setting-up-a-self-host-git-server/ 2021-05-29 - Setting up a Self Hosted Git Server +=> /posts/letsencrypt/2021-05-28/pre-and-post-validation-hooks-with-certbot/ 2021-05-28 - Pre and Post Validation Hooks with Certbot => /posts/letsencrypt/2021-05-27/wildcard-certificates-with-lets-encrypt/ 2021-05-27 - Wildcard Certificates with Let's Encrypt => /posts/nextcloud/2021-02-15/accessing-nextcloud-with-webdav-on-arch/ 2021-02-15 - Accessing Nextcloud With WebDAV on Arch => /posts/gemini/2021-02-08/how-to-host-your-own-gemini-site-in-the-cloud/ 2021-02-08 - How to Host Your Own Gemini Site in the Cloud diff --git a/www/index.html b/www/index.html index b2c8d42..5c46b20 100644 --- a/www/index.html +++ b/www/index.html @@ -18,7 +18,7 @@ -

The Home of David T. Sadler

Hello and welcome to my little bit of the internet where I occasionally write about things that interest me. You might find my posts interesting or you might not and that's okay.

Latest Posts

2021-06-05 - Xrandr: Failed to Get Size of Gamma for Output Default2021-05-29 - Setting up a Self Hosted Git Server2021-05-28 - Pre and Post Validation Hooks with Certbot2021-05-27 - Wildcard Certificates with Let's Encrypt2021-02-15 - Accessing Nextcloud With WebDAV on Arch2021-02-08 - How to Host Your Own Gemini Site in the Cloud2021-01-18 - Installing PHP 8 for Windows 102020-12-21 - Installing Laravel Homestead in Arch Linux2020-12-14 - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed2020-09-07 - Installing Zsh and Powerlevel10k on Arch Linux2020-08-31 - Enabling Audio in Arch Linux2020-08-24 - Pacman Cheat Sheet For Ubuntu Users2020-08-17 - Installing ST, DMENU and DWM in Arch Linux2020-07-13 - Sudo: sorry, you must have a tty to run sudo2020-06-22 - Granting Sudo Access to a User in Arch Linux2020-06-15 - Adding a User in Arch Linux2020-06-08 - Publishing Jigsaw Posts With Netlify Build Hooks2020-06-01 - Scheduling Posts in Jigsaw2020-05-25 - Installing Arch Linux on a Thinkpad X2202020-03-30 - Creating an Ebook With Markdown

All Posts

Post Archive

Tags

ArchGeminiGitJigsawLaravelLet's EncryptLinuxMarkdownNetlifyNextcloudPHP

Where to Find Me

GitHubGemini SiteEmail david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

+

The Home of David T. Sadler

Hello and welcome to my little bit of the internet where I occasionally write about things that interest me. You might find my posts interesting or you might not and that's okay.

Latest Posts

2021-06-13 - Backing Up a Git Repository2021-06-05 - Xrandr: Failed to Get Size of Gamma for Output Default2021-05-29 - Setting up a Self Hosted Git Server2021-05-28 - Pre and Post Validation Hooks with Certbot2021-05-27 - Wildcard Certificates with Let's Encrypt2021-02-15 - Accessing Nextcloud With WebDAV on Arch2021-02-08 - How to Host Your Own Gemini Site in the Cloud2021-01-18 - Installing PHP 8 for Windows 102020-12-21 - Installing Laravel Homestead in Arch Linux2020-12-14 - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed2020-09-07 - Installing Zsh and Powerlevel10k on Arch Linux2020-08-31 - Enabling Audio in Arch Linux2020-08-24 - Pacman Cheat Sheet For Ubuntu Users2020-08-17 - Installing ST, DMENU and DWM in Arch Linux2020-07-13 - Sudo: sorry, you must have a tty to run sudo2020-06-22 - Granting Sudo Access to a User in Arch Linux2020-06-15 - Adding a User in Arch Linux2020-06-08 - Publishing Jigsaw Posts With Netlify Build Hooks2020-06-01 - Scheduling Posts in Jigsaw2020-05-25 - Installing Arch Linux on a Thinkpad X2202020-03-30 - Creating an Ebook With Markdown

All Posts

Post Archive

Tags

ArchGeminiGitJigsawLaravelLet's EncryptLinuxMarkdownNetlifyNextcloudPHP

Where to Find Me

GitHubGemini SiteEmail david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

diff --git a/www/posts/atom.xml b/www/posts/atom.xml index db529ef..751a69c 100644 --- a/www/posts/atom.xml +++ b/www/posts/atom.xml @@ -4,8 +4,32 @@ https://davidtsadler.com/posts/atom.xml - 2021-06-05T12:00:00Z + 2021-06-13T12:00:00Z + Backing Up a Git Repository + https://davidtsadler.com/posts/git/2021-06-13/backing-up-a-git-repository/index.html + + David T. Sadler. + 2021-06-13T12:00:00Z + 2021-06-13T12:00:00Z + <h1>Backing Up a Git Repository</h1><blockquote>Sun 13th June 2021 By David T. Sadler.</blockquote><p>Below is a quick and dirty way in which I backup all my repositories that are hosted at git.davidtsadler.com.</p><pre><code class="shell">#!/bin/sh + +DATE_PREFIX=$(date +%Y%m%d) + +BACKUP_DIRECTORY=/tmp + +BACKUP_FILE=&quot;${BACKUP_DIRECTORY}/${DATE_PREFIX}-repositories.tar.gz&quot; + +BACKUP_FILES=&quot;${BACKUP_DIRECTORY}/*-repositories.tar.gz&quot; + +REPOSITORIES=/home/git/*.git + +tar -czf $BACKUP_FILE $REPOSITORIES + +find $BACKUP_FILES -mtime +3 -delete + +exit 0</code></pre><p>All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.</p><p>This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.</p><pre><code class="cron">0 3 * * * /usr/bin/backup_repositories &gt; /dev/null 2&gt;&amp;1</code></pre><p>It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.</p><h3>Links</h3><a href="/posts/git/2021-05-29/setting-up-a-self-host-git-server/">2021-05-29 - Setting up a Self Hosted Git Server</a><a href="/posts/git/">Git - Read More Posts.</a><p>I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> + Xrandr: Failed to Get Size of Gamma for Output Default https://davidtsadler.com/posts/linux/2021-06-05/xrandr-failed-to-get-size-of-gamma-for-output-default/index.html diff --git a/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html b/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html new file mode 100644 index 0000000..4c0c090 --- /dev/null +++ b/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html @@ -0,0 +1,41 @@ + + + + + + Backing Up a Git Repository + + + + + + + + + + + + + + +

Backing Up a Git Repository

Sun 13th June 2021 By David T. Sadler.

Below is a quick and dirty way in which I backup all my repositories that are hosted at git.davidtsadler.com.

#!/bin/sh
+
+DATE_PREFIX=$(date +%Y%m%d)
+
+BACKUP_DIRECTORY=/tmp
+
+BACKUP_FILE="${BACKUP_DIRECTORY}/${DATE_PREFIX}-repositories.tar.gz"
+
+BACKUP_FILES="${BACKUP_DIRECTORY}/*-repositories.tar.gz"
+
+REPOSITORIES=/home/git/*.git
+
+tar -czf $BACKUP_FILE $REPOSITORIES
+
+find $BACKUP_FILES -mtime +3 -delete
+
+exit 0

All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.

This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.

0 3 * * * /usr/bin/backup_repositories > /dev/null 2>&1

It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.

Links

2021-05-29 - Setting up a Self Hosted Git ServerGit - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+ + + + diff --git a/www/posts/git/atom.xml b/www/posts/git/atom.xml index 9513596..404b492 100644 --- a/www/posts/git/atom.xml +++ b/www/posts/git/atom.xml @@ -4,8 +4,32 @@ https://davidtsadler.com/posts/git/atom.xml - 2021-05-29T12:00:00Z + 2021-06-13T12:00:00Z + Backing Up a Git Repository + https://davidtsadler.com/posts/git/2021-06-13/backing-up-a-git-repository/index.html + + David T. Sadler. + 2021-06-13T12:00:00Z + 2021-06-13T12:00:00Z + <h1>Backing Up a Git Repository</h1><blockquote>Sun 13th June 2021 By David T. Sadler.</blockquote><p>Below is a quick and dirty way in which I backup all my repositories that are hosted at git.davidtsadler.com.</p><pre><code class="shell">#!/bin/sh + +DATE_PREFIX=$(date +%Y%m%d) + +BACKUP_DIRECTORY=/tmp + +BACKUP_FILE=&quot;${BACKUP_DIRECTORY}/${DATE_PREFIX}-repositories.tar.gz&quot; + +BACKUP_FILES=&quot;${BACKUP_DIRECTORY}/*-repositories.tar.gz&quot; + +REPOSITORIES=/home/git/*.git + +tar -czf $BACKUP_FILE $REPOSITORIES + +find $BACKUP_FILES -mtime +3 -delete + +exit 0</code></pre><p>All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.</p><p>This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.</p><pre><code class="cron">0 3 * * * /usr/bin/backup_repositories &gt; /dev/null 2&gt;&amp;1</code></pre><p>It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.</p><h3>Links</h3><a href="/posts/git/2021-05-29/setting-up-a-self-host-git-server/">2021-05-29 - Setting up a Self Hosted Git Server</a><a href="/posts/git/">Git - Read More Posts.</a><p>I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> + Setting up a Self Hosted Git Server https://davidtsadler.com/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html diff --git a/www/posts/git/index.html b/www/posts/git/index.html index a327641..314b4f6 100644 --- a/www/posts/git/index.html +++ b/www/posts/git/index.html @@ -18,7 +18,7 @@ -

The Home of David T. Sadler - All Posts About Git

2021-05-29 - Setting up a Self Hosted Git Server

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+

The Home of David T. Sadler - All Posts About Git

2021-06-13 - Backing Up a Git Repository2021-05-29 - Setting up a Self Hosted Git Server

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
diff --git a/www/posts/index.html b/www/posts/index.html index 1183586..0109fec 100644 --- a/www/posts/index.html +++ b/www/posts/index.html @@ -18,7 +18,7 @@ -

The Home of David T. Sadler - All Posts

2021-05-27 - Wildcard Certificates with Let's Encrypt2021-02-15 - Accessing Nextcloud With WebDAV on Arch2021-02-08 - How to Host Your Own Gemini Site in the Cloud2021-01-18 - Installing PHP 8 for Windows 102020-12-21 - Installing Laravel Homestead in Arch Linux2020-12-14 - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed2020-09-07 - Installing Zsh and Powerlevel10k on Arch Linux2020-08-31 - Enabling Audio in Arch Linux2020-08-24 - Pacman Cheat Sheet For Ubuntu Users2020-08-17 - Installing ST, DMENU and DWM in Arch Linux2020-07-13 - Sudo: sorry, you must have a tty to run sudo2020-06-22 - Granting Sudo Access to a User in Arch Linux2020-06-15 - Adding a User in Arch Linux2020-06-08 - Publishing Jigsaw Posts With Netlify Build Hooks2020-06-01 - Scheduling Posts in Jigsaw2020-05-25 - Installing Arch Linux on a Thinkpad X2202020-03-30 - Creating an Ebook With Markdown

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+

The Home of David T. Sadler - All Posts

2021-06-13 - Backing Up a Git Repository2021-06-05 - Xrandr: Failed to Get Size of Gamma for Output Default2021-05-29 - Setting up a Self Hosted Git Server2021-05-28 - Pre and Post Validation Hooks with Certbot2021-05-27 - Wildcard Certificates with Let's Encrypt2021-02-15 - Accessing Nextcloud With WebDAV on Arch2021-02-08 - How to Host Your Own Gemini Site in the Cloud2021-01-18 - Installing PHP 8 for Windows 102020-12-21 - Installing Laravel Homestead in Arch Linux2020-12-14 - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed2020-09-07 - Installing Zsh and Powerlevel10k on Arch Linux2020-08-31 - Enabling Audio in Arch Linux2020-08-24 - Pacman Cheat Sheet For Ubuntu Users2020-08-17 - Installing ST, DMENU and DWM in Arch Linux2020-07-13 - Sudo: sorry, you must have a tty to run sudo2020-06-22 - Granting Sudo Access to a User in Arch Linux2020-06-15 - Adding a User in Arch Linux2020-06-08 - Publishing Jigsaw Posts With Netlify Build Hooks2020-06-01 - Scheduling Posts in Jigsaw2020-05-25 - Installing Arch Linux on a Thinkpad X2202020-03-30 - Creating an Ebook With Markdown

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
diff --git a/www/sitemap.xml b/www/sitemap.xml index 12609e1..b83b2c5 100644 --- a/www/sitemap.xml +++ b/www/sitemap.xml @@ -1,6 +1,10 @@ + https://davidtsadler.com/posts/git/2021-06-13/backing-up-a-git-repository/index.html + 2021-06-13T12:00:00Z + never + https://davidtsadler.com/posts/linux/2021-06-05/xrandr-failed-to-get-size-of-gamma-for-output-default/index.html 2021-06-05T12:00:00Z never -- cgit v1.2.3-13-gbd6f