Create a dated backup copy of a file
back up a config file before editing | save a copy before changing a file | copy with timestamp in the name | create a bak file | cp | backup | filesCaution: This command changes the system. Understand what it does before you run it.
cp -p -- /var/www/vhosts/example.com/httpdocs/.htaccess /var/www/vhosts/example.com/httpdocs/.htaccess.bak-$(date +%F-%H%M)Copies the file into the same folder and appends .bak- plus date and time. Several changes on the same day therefore never overwrite each other. -p keeps permissions and timestamps.
Note: .bak files in the web root may be downloadable. For files with credentials such as wp-config.php, store the copy outside httpdocs.
Also searched as
- back up a config file before editing
- save a copy before changing a file
- copy with timestamp in the name
- create a bak file