{"id":177,"date":"2026-04-19T10:32:07","date_gmt":"2026-04-19T09:32:07","guid":{"rendered":"https:\/\/vpp.dk\/?linux_trick=create-a-timestamped-backup-of-a-file"},"modified":"2026-04-19T10:32:07","modified_gmt":"2026-04-19T09:32:07","slug":"create-a-timestamped-backup-of-a-file","status":"publish","type":"linux_trick","link":"https:\/\/vpp.dk\/?linux_trick=create-a-timestamped-backup-of-a-file","title":{"rendered":"Create a timestamped backup of a file"},"content":{"rendered":"<p>Before editing a config, make a dated backup with a one-liner. The $(date) sub-shell appends the current timestamp.<\/p>\n","protected":false},"template":"","meta":{"_trick_code":"cp nginx.conf nginx.conf.$(date +%Y%m%d_%H%M%S).bak\n\n# Backup and keep last 5 only:\ncp important.conf important.conf.$(date +%Y%m%d).bak\nls -t important.conf.*.bak | tail -n +6 | xargs rm -f","_trick_uploader":"backupbro"},"trick_category":[16,22],"class_list":["post-177","linux_trick","type-linux_trick","status-publish","hentry","trick_category-file-management","trick_category-scripting"],"_links":{"self":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick"}],"about":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/types\/linux_trick"}],"wp:attachment":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"trick_category","embeddable":true,"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftrick_category&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}