Skip to content

Commit

Permalink
Docs (#58)
Browse files Browse the repository at this point in the history
* update automation.md to include filewatching service

* add note about starting the stoping service for bigger edits which example image

* make a note instead of step 5 and a slighty smaller image

* image should now be under the text

* maybe now its placed correctly

* now its correct
  • Loading branch information
Tylerjet authored Feb 14, 2024
1 parent 224c06e commit aee04e9
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions docs/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ There are a couple different methods for automating backups you can choose to us
## Backup on boot
1. Create the service file in systemd
```shell
sudo nano /etc/systemd/system/klipper-backup.service
sudo nano /etc/systemd/system/klipper-backup-on-boot.service
```
2. Copy and paste the below text (be sure to uncomment the correct `after=` and `wants=` lines based on if your linux install is using network manager)
```shell
[Unit]
Description=Klipper Backup Service
Description=Klipper Backup On-boot Service
#Uncomment below lines if using network manager
#After=NetworkManager-wait-online.service
#Wants=NetworkManager-wait-online.service
Expand All @@ -27,8 +27,8 @@ WantedBy=default.target
3. Reload the service daemon, enable the service and start the service
```
sudo systemctl daemon-reload
sudo systemctl enable klipper-backup.service
sudo systemctl start klipper-backup.service
sudo systemctl enable klipper-backup-on-boot.service
sudo systemctl start klipper-backup-on-boot.service
```

## Cron
Expand All @@ -49,3 +49,49 @@ crontab -e
0 */4 * * * $HOME/klipper-backup/script.sh
```
This tells cron to run the backup script every 4 hours. You can find other cron examples here: <a href="https://crontab.guru/examples.html" target="_blank">https://crontab.guru/examples.html</a>

## Backup on file changes
!!! warning "Important Info"
The following service relies on the inotify-tools package.

To install the package run ```sudo apt-get install inotify-tools``` in your terminal.
2. Create the service file in systemd
```shell
sudo nano /etc/systemd/system/klipper-backup-filewatch.service
```
3. Copy and paste the below text (be sure to uncomment the correct `after=` and `wants=` lines based on if your linux install is using network manager)
```shell
[Unit]
Description=Klipper Backup Filewatch Service
#Uncomment below lines if using network manager
#After=NetworkManager-wait-online.service
#Wants=NetworkManager-wait-online.service
#Uncomment below lines if not using network manager
#After=network-online.target
#Wants=network-online.target

[Service]
User={replace with your username}
Type=simple
ExecStart=/bin/bash -c '\
exclude_pattern=".swp|.tmp|printer-[0-9]*_[0-9]*.cfg|.bak|.bkp"; \
inotifywait -mrPq -e close_write -e move -e delete --exclude "$exclude_pattern" $HOME/printer_data/config/ | \
while read -r path event file; do \
echo "Event Type: $event, Watched Path: $path, File Name: $file"; \
bash -c '\''bash $HOME/klipper-backup/script.sh "Files modified - $(date +\"%%x - %%X\")"'\'' > /dev/null 2>&1; \
done'

[Install]
WantedBy=default.target
```
4. Reload the service daemon, enable the service and start the service
```
sudo systemctl daemon-reload
sudo systemctl enable klipper-backup-filewatch.service
sudo systemctl start klipper-backup-filewatch.service
```

!!! note
When making large edits where you might want to stop the service you can go into your service manager and stop the service below is an example of its location in fluidd.
![fluidd-service-manager](https://i.imgur.com/kOct70v.gif)

0 comments on commit aee04e9

Please sign in to comment.