The following example uses crontab to create backups, and 

1.

Connect to the web server, I'll use SSH

ssh root@<IP>
2.

Edit the crontab (the editor used by the following command can be set with the $VISUAL or $EDITOR environment variables)

crontab -e
3.

When editing the crontab, commands must begin with a definition of how often the command should be run. See https://crontab.guru/ for help customizing the timing

# at 3AM on the first of every month, delete backups older than 181 days (half a year)
0 3 1 * * test -x && test -d /var/www_backup/ && /usr/bin/find && /usr/bin/find /var/www_backup/craft-assets-*.tar.gz -mtime +181 -delete

# at 4am on the first of every month, create a backup archive
0 4 1 * * test -x /bin/tar && test -d /var/www_backup/ && /bin/tar -cpzf /var/www_backup/craft-assets-`/bin/date "+\%F"`.tar.gz -C /var/www/html/ assets/

Related Articles


Having trouble finding something?

Submit the content update/request form, and we’ll be sure to make the change or find the answer.