GOPHERSPACE.DE - P H O X Y
gophering on yasendfile.org
+--------------------------------------------------------------------------+
|# Tips and Tricks - Blog                                                  |
| Written by Wim Stockman - last updated on 2023-01-12               |
+--------------------------------------------------------------------------+
### Autologin tty on Artix Runit 
Thu Jan 12 08:04:45 AM UTC 2023
Edit file /etc/runit/sv/agetty-tty1/conf
>Change line: GETTY_ARGS="--noclear"
>To: GETTY_ARGS="--autologin yourusername --noclear"

### Add Todays date in a groff document.
Sat Dec 17 04:07:17 PM UTC 2022
Groff has some built-in Registers.
For the date it has:
```
\n[dw] Day of the week(1-7)
\n[dy] Day of the Month(1-31)
\n[mo] Current Month(1-12)
\n[yr] The Current Year minus 1900 (old version)
\n[year] The Current Year. (new version)
```
For Time is has the built-in registers:
These get initialized at start-up of groff
```
\n[seconds] 0-59
\n[minutes] 0-59
\n[hours] 0-23
```
So to display date in iso style: 
> \n[year]-\n(mo-\n(dy

### Convert epoch date or UNIXTIMESTAMP to other format date
Sat Jun 18 03:42:28 PM CEST 2022
> date -d @1652997600 --iso-8601
Result: 2022-05-20


### Get all the awk scripts in a dir presented in slmenu.  Choose one and execute it
Fri Mar 19 21:16:01 UTC 2021
=>https://github.com/wimstockman/slmenu Slmenu is a cli version of dmenu. (source)

* Get all scripts in menu
```
    awk -f ./$(ls *.awk | slmenu -i )
```

* Select script and apply to all files in directory
```
    awk -f ./$(ls *.awk | slmenu -i ) $(ls -tr dir/*)
```

* Select script and apply to latest created file in directory
```
    awk -f ./$(ls *.awk | slmenu -i ) $(ls -tr dir/* | tail -n1)
```

### Backup your server mariadb database to local computer
Fri Mar 19 21:43:17 UTC 2021
```
ssh -C host mysqldump yourdatabase > yourdatabase.sql && gzip yourdatabase.sql
```

The -C in ssh is for compression which saves a lot of time over slower internet connections.
The redirect symbol(">") sents the screen output from the remote machine to the local machine into a file yourdatabase.sql
After succes,thats what the double && are for, gzip database for storage.

### Restore your servers mariadb database

copy your backup file to the server
e.g. with scp, rsync ...

```
scp yourdatabase.sql.gz yourserver:/tmp/
ssh yourserver
cd /tmp
gunzip yourdatabase.sql.gz ; mysql yourdatabase < yourdatabase.sql
```