How to Back-Up webpage like lftp and mysqldump automatically Truenas Scale

kzsolt4444

Cadet
Joined
Oct 29, 2022
Messages
9
Hi!

Im here to ask, how would you do it on Truenas natively, or with using any app:
Im developing a few wordpress page, which is hosted somewhere else (not by me). Since i want to own the backups on my HDD, i regulary making a backup manually everytime using Total commander on windows, for back-uping the complete FTP content, + i goes up to php myadmin, for making a back-up of the current mysql db.

Im just wondering if i can automate this somehow on my truenas server? In theory it would be very-very easy with using some almost base linux command like "lftp" and my "mysqldump " but it isnt working, because they are not installed as default package to the kernel which is used by the recent truenas, and i cannot use any apt install command to have them on the system. How else would you do this? What are the suggestions?

It would be so easy to just write a bash script, using lftp and mysqldump in it, and automate it with a cron job. (But i cannot do it, because these packages are unknown for truenas.)

So can you recommend me a way, how would you do it?
Thanks!
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
So can you recommend me a way, how would you do it?
Create an app using a container that has those utilities (and maybe cron) in it, then run your script in that container (with cron if you're comfortable that it's working).
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
rsync and ssh are both available on TrueNAS so you would not even need to install additional software, let alone an app, to script a backup for a remote Wordpress installation.

If you can authenticate as a user that can read all file system assets with ssh on the remote system without a password and if you also have a remote MySLQ user that can dump the database, it's as easy as - rough sketch:
Code:
date=$(date +%Y%m%d)
mkdir -p /mnt/<pool>/wordpress1/file-backup /mnt/<pool>/wordpress1/db-backup
cd /mnt/<pool>/wordpress1
rsync -az <remote-user>@<remote-server>:/<remote>/<path> ./file-backup/${date}
ssh -e none <remote-user>@<remote-server> "/usr/bin/mysqldump --opt --quote-names --hex-blob -u<user> -p<password> <dbname> | gzip -c" > db-backup/${date}.sql.gz

Add expiry of older backups according to your needs - no additional tooling required.
 
Last edited:
Top