Skip to main content
fixed my name
Source Link
Panki
  • 7.2k
  • 3
  • 28
  • 37

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Use of nohup (as suggested by PankyPanki) is probably the best solution regarding portability in the *nix world. However, ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Use of nohup (as suggested by Panky) is probably the best solution regarding portability in the *nix world. However, ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Use of nohup (as suggested by Panki) is probably the best solution regarding portability in the *nix world. However, ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

Add another alternative
Source Link
kaliko
  • 603
  • 1
  • 8
  • 15

tmux (or screen) is indeed a nice solution, but it needs an extra package.

UbuntuUse of nohup (as suggested by Panky) is probably the best solution regarding portability in the *nix world. However, ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Use of nohup (as suggested by Panky) is probably the best solution regarding portability in the *nix world. However, ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.

Source Link
kaliko
  • 603
  • 1
  • 8
  • 15

tmux (or screen) is indeed a nice solution, but it needs an extra package.

Ubuntu 16 came with systemd, then you could use systemd-run to launch a command:

systemd-run --unit=my_backup --remain-after-exit mysqldump --single-transaction --add-drop-table -h <host> -u <user> -p <db_name> -r magento2_db-20201110.sql

You can then access status and outputs with regular systemd command:

journalctl -b -u my_backup
systemctl status my_backup

You can even easily limit resources your backup uses with extra systemd-run options, cf man 1 systemd-run.

Some explanations:

  • --remain-after-exit is needed to have my_backup.service lying around even after mysqldump finished in order to consult the service status and log (through journalctl)
  • --unit allows to name as you whish to service launched by systemd-run
  • I used mysqldump option -r to avoid stdout redirection.

Using systemd-run to launch any command permits closing remote ssh access without terminating the command.