update from sparkleup
This commit is contained in:
parent
45d866424d
commit
ab63cf4ef5
101
work/gitea-2.md
101
work/gitea-2.md
|
@ -146,10 +146,107 @@ ROOT = <^>/mnt/gitea<^>/gitea-repositories
|
|||
|
||||
If you already have an instance of Gitea installed and running, you will still be able to store your data on a separate Linux volume, but it will require some care in ensuring that all of your data remains both safe and accessible to Gitea.
|
||||
|
||||
As with any operation involving your data, it is important to ensure that you have an up-to-date backup of everything. In this case, this means a back up of all of the files in your data directory (the SSH files, the `gitea-repositories` and `lfs` directories, the database, and so on) to a safe location.
|
||||
<$>[note]
|
||||
**Note:** As with any operation involving your data, it is important to ensure that you have an up-to-date backup of everything. In this case, this means a back up of all of the files in your data directory (the SSH files, the `gitea-repositories` and `lfs` directories, the database, and so on) to a safe location.
|
||||
<$>
|
||||
|
||||
There are two options for moving your data to a new volume. The first way is to copy your Gitea data to a secondary location, then turn the original location into a mount point for your Linux volume. When you copy your data back into that location, you will be copying it onto that volume, and no changes will be required within Gitea itself; it will simply continue as it did before. If, however, you do not want to mount the entire device to that destination (for example, if your Gitea data will not be the only thing on that volume), then a second option is to move all of your Gitea data to a new location on that volume and instruct Gitea itself to use that location.
|
||||
|
||||
No matter which option you choose, first, stop the Gitea web service.
|
||||
|
||||
If you are using Gitea installed via Docker Compose, use `docker-compose` to stop the service. While inside the same directory containing the `docker-compose.yml` file, run:
|
||||
|
||||
```command
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
If you have installed it as a Linux service, use the `systemctl` command:
|
||||
|
||||
```command
|
||||
sudo systemctl stop gitea
|
||||
```
|
||||
|
||||
Once Gitea has been stopped, move the entire contents of the data directory to the mount point made in step 1:
|
||||
|
||||
```command
|
||||
mv * /mnt/gitea
|
||||
```
|
||||
|
||||
Ensure that all files have been moved by listing all of the current directory's contents:
|
||||
|
||||
```command
|
||||
ls -la
|
||||
```
|
||||
|
||||
You should only see the current and parent directory entries. The result should look something like this:
|
||||
|
||||
```
|
||||
total 8
|
||||
drwxrwxr-x 2 mscottclary mscottclary 4096 Jun 27 13:56 ./
|
||||
drwxr-xr-x 7 mscottclary mscottclary 4096 Jun 27 13:56 ../
|
||||
```
|
||||
|
||||
Once all of the data has been moved, change to that directory:
|
||||
|
||||
```command
|
||||
cd /mnt/gitea
|
||||
```
|
||||
|
||||
Using `ls`, ensure that everything looks correct. As before, you should see the `ssh`, `git`, and `gitea` directories. If you are using SQLite as a database to manage Gitea, you should also see a file named `gitea.db` in the `gitea` directory.
|
||||
|
||||
When you're sure that all data has been moved, it's time to mount the Linux volume to the data directory.
|
||||
|
||||
First, move to the parent directory of the data directory.
|
||||
|
||||
```command
|
||||
cd <^>/home/sammy/gitea/..<^>
|
||||
```
|
||||
|
||||
As before, use the `mount` command, but this time, use the directory you just emptied as the destination:
|
||||
|
||||
```command
|
||||
sudo mount -o defaults,noatime /dev/disk/by-id/<^>your_disk_id<^> gitea
|
||||
```
|
||||
|
||||
Now, when you look inside that directory, you should see all of your files in place:
|
||||
|
||||
```command
|
||||
ls -la gitea
|
||||
```
|
||||
|
||||
This command should output the expected information. Note that, depending on your volume's file system type, you may see an additional directory named `lost+found`; this is normal and part of everyday file system use.
|
||||
|
||||
```
|
||||
total 36
|
||||
drwxr-xr-x 6 root root 4096 Jun 27 13:58 ./
|
||||
drwxrwxr-x 3 mscottclary mscottclary 4096 Jun 27 02:23 ../
|
||||
drwxr-xr-x 5 git git 4096 Jun 23 22:42 git/
|
||||
drwxr-xr-x 12 git git 4096 Jun 27 00:00 gitea/
|
||||
drwx------ 2 root root 16384 Jun 27 03:46 lost+found/
|
||||
drwx------ 2 root root 4096 Jun 23 22:34 ssh/
|
||||
```
|
||||
|
||||
As mentioned, if you would like Gitea to use a directory within the Linux volume, there is an additional step you need to complete before bringing Gitea back up. For example, say that you want to use a folder named `scm` on your volume mounted on `/mnt/gitea`. After moving all of your Gitea data to `/mnt/gitea/scm`, you will need to create a symbolic link from your old data directory to the new one. For this you will use the `ln` command:
|
||||
|
||||
```command
|
||||
sudo ln -s /mnt/gitea/scm gitea
|
||||
```
|
||||
|
||||
At this point, you can restart Gitea. If you are using Gitea as a Linux service, run:
|
||||
|
||||
```command
|
||||
sudo systemctl restart gitea
|
||||
```
|
||||
|
||||
If you are running Gitea as a Docker container using Docker Compose, run:
|
||||
|
||||
|
||||
```command
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Step 3 — Creating Snapshots of Volumes (optional)
|
||||
Now that everything is up and running, visit your Gitea instance in the browser and ensure that everything works as expected. You should be able to create new objects in Gitea such as repositories, issues, and so on. If you set Gitea up with an SSH shim, you should also be able to check out and push to repositories using `git clone` and `git push`.
|
||||
|
||||
## Conclusion
|
||||
|
||||
In this tutorial, you moved all of your Gitea data to a Linux volume. Volumes such as these are very flexible and provide many benefits.such as allowing you to store all of your data on larger disks, RAID volumes, networked file systems, or using block storage such as DigitalOcean Volumes or Amazon EBS to reduce storage expenses. It also allows you to snapshot entire disks for backup so that you can restore their contents in event of a catastrophic failure.
|
||||
|
|
Loading…
Reference in New Issue