mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
docs: Update documentation (#6430)
* Documentation corrections * fix import * add firewall note * npm run format:fix * fixs * npm run format:fix * space * fix note * admin-jobs.png image update + fixes * Storage Template.md update * Add new Troubleshooting about symbolic link in library * Updating the libraries.md * Updating the libraries.md * Corrections * add `/` * ... * Add Python script to remove-offline-files.md * npm run format:fix * Add info about HDR in FAQ * My wrong merge * add info about symlink * [Community] + PowerShell * add 360 photo support to Features in README * add info about remote ML and info about orphaned files from the external library to the scripts page * Typo * add note about storage locations * add info about Purge for portainer and link to info about asset types and storage locations * npm run format:fix * Add FAQ about "faces" that aren't faces * Update docs/docs/administration/backup-and-restore.md * Update docs/docs/administration/backup-and-restore.md --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
parent
4eca2b0f34
commit
19d4c5e9f7
9 changed files with 273 additions and 22 deletions
|
|
@ -4,8 +4,17 @@ A short guide on connecting [pgAdmin](https://www.pgadmin.org/) to Immich.
|
|||
|
||||
:::note
|
||||
|
||||
- In order to connect to the database the immich_postgres container **must be running**.
|
||||
- The passwords and usernames used below match the ones specified in the example `.env` file. If changed, please use actual values instead.
|
||||
In order to connect to the database the immich_postgres container **must be running**.
|
||||
|
||||
The passwords and usernames used below match the ones specified in the example `.env` file. If changed, please use actual values instead.
|
||||
|
||||
**Optional:** To connect to the database **outside** of your Docker's network:
|
||||
|
||||
- Expose port 5432 in your `docker-compose.yml` file.
|
||||
- Edit the PostgreSQL [`pg_hba.conf`](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file.
|
||||
- Make sure your firewall does not block access to port 5432.
|
||||
Note that exposing the database port increases the risk of getting attacked by hackers.
|
||||
Make sure to remove the binding port after finishing the database's tasks.
|
||||
|
||||
:::
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ To alleviate [performance issues on low-memory systems](/docs/FAQ.mdx#why-is-imm
|
|||
- Copy the following `docker-compose.yml` to your ML system.
|
||||
- Start the container by running `docker-compose up -d` or `docker compose up -d` (depending on your Docker version).
|
||||
|
||||
:::note Info
|
||||
Starting with version v1.93.0 face detection work and face recognize were split. From now on face detection is done in the immich_machine_learning service, but facial recognition is done in the immich_microservices service.
|
||||
:::
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,146 @@
|
|||
# Remove Offline Files
|
||||
# Remove Offline Files [Community]
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
:::note
|
||||
**Before running the script**, please make sure you have a [backup](/docs/administration/backup-and-restore) of your assets and database
|
||||
**Before running the script**, please make sure you have a [backup](/docs/administration/backup-and-restore) of your assets and database.
|
||||
:::
|
||||
|
||||
:::info
|
||||
**None** of the scripts can delete orphaned files from the external library.
|
||||
:::
|
||||
|
||||
This page is a guide to get rid of offline files from the repair page.
|
||||
|
||||
<Tabs>
|
||||
|
||||
<TabItem value="Python script (Best way)" label="Python script (Best way)">
|
||||
|
||||
This way works by retrieving a file that contains a list of all the files that are defined as offline files, running a script that uses the [Immich API](/docs/api/delete-assets) in order to remove the offline files.
|
||||
|
||||
1. Create an API key under Admin User -> Account Settings -> API Keys -> New API Key -> Copy to clipboard.
|
||||
2. Copy and save the code to file -> `Immich Remove Offline Files.py`.
|
||||
3. Run the script and follow the instructions.
|
||||
|
||||
:::note
|
||||
You might need to run `pip install halo tabulate tqdm` if these dependencies are missing on your machine.
|
||||
:::
|
||||
|
||||
```bash title='Python'
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Note: you might need to run "pip install halo tabulate tqdm" if these dependencies are missing on your machine
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import requests
|
||||
|
||||
from datetime import datetime
|
||||
from halo import Halo
|
||||
from tabulate import tabulate
|
||||
from tqdm import tqdm
|
||||
from urllib.parse import urlparse
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(description='Fetch file report and delete orphaned media assets from Immich.')
|
||||
parser.add_argument('--apikey', help='Immich API key for authentication')
|
||||
parser.add_argument('--immichaddress', help='Full address for Immich, including protocol and port')
|
||||
parser.add_argument('--no_prompt', action='store_true', help='Delete orphaned media assets without confirmation')
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
def filter_entities(response_json, entity_type):
|
||||
return [
|
||||
{'pathValue': entity['pathValue'], 'entityId': entity['entityId'], 'entityType': entity['entityType']}
|
||||
for entity in response_json.get('orphans', []) if entity.get('entityType') == entity_type
|
||||
]
|
||||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
try:
|
||||
if args.apikey:
|
||||
api_key = args.apikey
|
||||
else:
|
||||
api_key = input('Enter the Immich API key: ')
|
||||
|
||||
if args.immichaddress:
|
||||
immich_server = args.immichaddress
|
||||
else:
|
||||
immich_server = input('Enter the full web address for Immich, including protocol and port: ')
|
||||
immich_parsed_url = urlparse(immich_server)
|
||||
base_url = f'{immich_parsed_url.scheme}://{immich_parsed_url.netloc}'
|
||||
api_url = f'{base_url}/api'
|
||||
file_report_url = api_url + '/audit/file-report'
|
||||
headers = {'x-api-key': api_key}
|
||||
|
||||
print()
|
||||
spinner = Halo(text='Retrieving list of orphaned media assets...', spinner='dots')
|
||||
spinner.start()
|
||||
|
||||
try:
|
||||
response = requests.get(file_report_url, headers=headers)
|
||||
response.raise_for_status()
|
||||
spinner.succeed('Success!')
|
||||
except requests.exceptions.RequestException as e:
|
||||
spinner.fail(f'Failed to fetch assets: {str(e)}')
|
||||
|
||||
person_assets = filter_entities(response.json(), 'person')
|
||||
orphan_media_assets = filter_entities(response.json(), 'asset')
|
||||
|
||||
num_entries = len(orphan_media_assets)
|
||||
|
||||
if num_entries == 0:
|
||||
print('No orphaned media assets found; exiting.')
|
||||
return
|
||||
|
||||
else:
|
||||
if not args.no_prompt:
|
||||
table_data = []
|
||||
for asset in orphan_media_assets:
|
||||
table_data.append([asset['pathValue'], asset['entityId']])
|
||||
print(tabulate(table_data, headers=['Path Value', 'Entity ID'], tablefmt='pretty'))
|
||||
print()
|
||||
|
||||
if person_assets:
|
||||
print('Found orphaned person assets! Please run the "RECOGNIZE FACES > ALL" job in Immich after running this tool to correct this.')
|
||||
print()
|
||||
|
||||
if num_entries > 0:
|
||||
summary = f'There {"is" if num_entries == 1 else "are"} {num_entries} orphaned media asset{"s" if num_entries != 1 else ""}. Would you like to delete {"them" if num_entries != 1 else "it"} from Immich? (yes/no): '
|
||||
user_input = input(summary).lower()
|
||||
print()
|
||||
|
||||
if user_input not in ('y', 'yes'):
|
||||
print('Exiting without making any changes.')
|
||||
return
|
||||
|
||||
with tqdm(total=num_entries, desc="Deleting orphaned media assets", unit="asset") as progress_bar:
|
||||
for asset in orphan_media_assets:
|
||||
entity_id = asset['entityId']
|
||||
asset_url = f'{api_url}/asset'
|
||||
delete_payload = json.dumps({'force': True, 'ids': [entity_id]})
|
||||
headers = {'Content-Type': 'application/json', 'x-api-key': api_key}
|
||||
response = requests.delete(asset_url, headers=headers, data=delete_payload)
|
||||
response.raise_for_status()
|
||||
progress_bar.set_postfix_str(entity_id)
|
||||
progress_bar.update(1)
|
||||
print()
|
||||
print('Orphaned media assets deleted successfully!')
|
||||
except Exception as e:
|
||||
print()
|
||||
print(f"An error occurred: {str(e)}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
```
|
||||
|
||||
Thanks to [DooMRunneR](https://discord.com/channels/979116623879368755/1179655214870040596/1194308198413373482) and [Sircharlo](https://discord.com/channels/979116623879368755/1179655214870040596/1195038609812758639) for writing this script.
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="Bash and PowerShell script" label="Bash and PowerShell script" default>
|
||||
|
||||
This way works by downloading a JSON file that contains a list of all the files that are defined as offline files, running a script that uses the [Immich API](/docs/api/delete-assets) in order to remove the offline files.
|
||||
|
||||
1. Create an API key under Admin User -> Account Settings -> API Keys -> New API Key -> Copy to clipboard.
|
||||
|
|
@ -15,13 +150,13 @@ This way works by downloading a JSON file that contains a list of all the files
|
|||
|
||||
## Script for Linux based systems:
|
||||
|
||||
```bash
|
||||
```bash title='Bash'
|
||||
awk -F\" '/entityId/ {print $4}' orphans.json | while read line; do curl --location --request DELETE 'http://YOUR_IP_HERE:2283/api/asset' --header 'Content- Type: application/json' --header 'x-api-key: YOUR_API_KEY_HERE' --data '{ "force": true, "ids": ["'"$line"'"]}';done
|
||||
```
|
||||
|
||||
## Script for the Windows system (run through PowerShell):
|
||||
|
||||
```powershell
|
||||
```powershell title='PowerShell'
|
||||
Get-Content orphans.json | Select-String -Pattern 'entityId' | ForEach-Object {
|
||||
$line = $_ -split '"' | Select-Object -Index 3
|
||||
$body = [pscustomobject]@{
|
||||
|
|
@ -36,3 +171,6 @@ Get-Content orphans.json | Select-String -Pattern 'entityId' | ForEach-Object {
|
|||
```
|
||||
|
||||
Thanks to [DooMRunneR](https://discord.com/channels/979116623879368755/1179655214870040596/1194308198413373482) for writing this script.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue