Migrating your Gitea database involves creating a proper backup of all the data: both the database itself (containing repositories, issues, users, etc.) and any files stored on disk (like repositories and configuration data). Here's a step-by-step guide:
Step 1: Stop the Gitea Service
Before migrating or backing up, it's best to stop the Gitea instance to avoid active changes during the backup process. Run the following:
For systems using systemctl:
bash
sudo systemctl stop gitea
Alternatively, if Gitea is running via a binary or other process manager, ensure it’s stopped gracefully.
Step 2: Backup the Gitea Database
Gitea supports different database types like SQLite, MySQL/MariaDB, and PostgreSQL. The specific command depends on the database engine you’re using.
Case 1: SQLite (default)
If you’re using SQLite (default for smaller setups), you simply need to back up the database file. The file is usually located in the data/ directory inside the Gitea installation folder.
Navigate to the data directory:
bash
cd /var/lib/gitea/data
Copy the SQLite database file (e.g., gitea.db) to a backup location:
bash
cp gitea.db /path/to/backup/gitea.db
Case 2: MySQL or MariaDB
For MySQL or MariaDB, you can use mysqldump to create a backup of the Gitea database.
Run the following command (replace with your actual database details):
Good luck! Let me know if you have any questions. 😊
To pull data from a mobile device to a PC using adb for folders that require root access, you need to make sure the device allows root permissions with adb. By default, adb won't have permissions to access certain folders unless the device is rooted. Below are the steps to achieve this:
Prerequisites
Enable Developer Options on your device:
Go to Settings > About phone and tap Build number 7 times to enable developer mode.
Enable USB Debugging:
In Settings > Developer options, enable USB Debugging.
Root Access:
Your device must be rooted to access protected directories. If your device is not rooted, you won't have access to system directories or folders requiring elevated privileges.
A rooted device also needs a Superuser (SU) application (like Magisk or SuperSU) for granting adb root access.
Install ADB:
Make sure adb is installed on your PC and added to the PATH environment variable. You can download ADB as part of the Android SDK Platform Tools.
Steps to Pull Files/Folders with Root Access using ADB
1. Verify Connection to the Mobile Device
First, ensure your PC can detect the device via adb:
bash
adb devices
You should see your device listed with a serial number. If it’s not detected, troubleshoot USB connection issues (e.g., enabling USB debugging, checking drivers, etc.).
2. Restart ADB as Root (adb root)
To access root-only folders, restart adb with root permissions:
bash
adb root
If successful, you’ll see: restarting adbd as root.
If you see adbd cannot run as root in production builds, it means your device’s ROM does not allow root via adb. You’ll need to install a custom ROM or patch adbd.
3. Grant Root Access on the Device
If your device is rooted and it uses a root manager app like Magisk:
A popup will appear on the phone asking if you want to grant adb root privileges.
Grant the permission.
If the popup does not appear, ensure that adbd is correctly configured to allow root access. This is commonly configured in root manager apps like Magisk.
4. Access the Root Directory (adb shell)
Enter the device shell with root privileges:
bash
adb shell
You should now have access to root-restricted directories here:
bash
ls /
You can exit the shell at any time with exit.
5. Navigate to the Protected Directory
Navigate to the directory containing the data you want. For example:
bash
cd /data/data/
Protected system directories requiring root access include:
/data: Application data, caches, etc.
/data/data/<package_name>: App-specific data.
/system, /vendor, etc.: System files.
Verify file accessibility:
bash
ls -al
6. Pull Files or Directories to Your PC
Use the adb pull command to copy the file or folder to your PC. For example: