diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-06-13 22:48:53 +0100 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-06-13 22:48:53 +0100 |
| commit | 81d1cb4f38a12b27b92fcccf182c3e4fd05c9271 (patch) | |
| tree | b517e2682147dc4531764417d05df0287876c7e0 /www/posts/git | |
| parent | dfb89f1877d01cf2f7d62e13725e81ecede062fb (diff) | |
Add Backing Up a Git Repository
Diffstat (limited to 'www/posts/git')
| -rw-r--r-- | www/posts/git/2021-06-13/backing-up-a-git-repository/index.html | 41 | ||||
| -rw-r--r-- | www/posts/git/atom.xml | 26 | ||||
| -rw-r--r-- | www/posts/git/index.html | 2 |
3 files changed, 67 insertions, 2 deletions
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 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Backing Up a Git Repository</title> + <link rel="shortcut icon" href="/images/favicon.png"> + <link rel="stylesheet" href="/css/site.css"> + <link href="/posts/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts"/> + <link href="/posts/arch/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Arch"/> + <link href="/posts/gemini/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Gemini"/> + <link href="/posts/jigsaw/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Jigsaw"/> + <link href="/posts/laravel/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Laravel"/> + <link href="/posts/linux/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Linux"/> + <link href="/posts/markdown/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Markdown"/> + <link href="/posts/netlify/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Netlify"/> + <link href="/posts/nextcloud/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About Nextcloud"/> + <link href="/posts/php/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About PHP"/> + </head> + <body> + <section><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="${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</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 > /dev/null 2>&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></section> + <script defer src="/js/highlight.min.js"></script> + <script defer src="/js/site.js"></script> + </body> +</html> 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 @@ <id>https://davidtsadler.com/posts/git/atom.xml</id> <link rel="alternate" type="text/html" href="https://davidtsadler.com/posts/git/index.html"/> <link rel="self" type="application/atom+xml" href="https://davidtsadler.com/posts/git/atom.xml"/> - <updated>2021-05-29T12:00:00Z</updated> + <updated>2021-06-13T12:00:00Z</updated> <entry> + <title type="text">Backing Up a Git Repository</title> + <id>https://davidtsadler.com/posts/git/2021-06-13/backing-up-a-git-repository/index.html</id> + <link rel="alternate" type="text/html" href="https://davidtsadler.com/posts/git/2021-06-13/backing-up-a-git-repository/index.html"/> + <author><name>David T. Sadler.</name></author> + <published>2021-06-13T12:00:00Z</published> + <updated>2021-06-13T12:00:00Z</updated> + <content type="html"><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></content> +</entry><entry> <title type="text">Setting up a Self Hosted Git Server</title> <id>https://davidtsadler.com/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html</id> <link rel="alternate" type="text/html" href="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 @@ <link href="/posts/php/atom.xml" type="application/atom+xml" rel="alternate" title="The Home of David T. Sadler - All Posts About PHP"/> </head> <body> - <section><h1>The Home of David T. Sadler - All Posts About Git</h1><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><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></section> + <section><h1>The Home of David T. Sadler - All Posts About Git</h1><a href="/posts/git/2021-06-13/backing-up-a-git-repository/">2021-06-13 - Backing Up a Git Repository</a><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><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></section> <script defer src="/js/highlight.min.js"></script> <script defer src="/js/site.js"></script> </body> |
