AleFeri

Why I Built Safe CP

Rust6/10/2026

Why I Built Safe CP

Why I Built Safe CP

Copying files from the terminal is fast and simple. However, a small mistake can replace an important file. The normal cp command does not give you an easy way to go back.

For this reason, I created Safe CP, a small command-line tool written in Rust.

What Safe CP Does

Safe CP copies a file like the normal cp command. The main difference is what happens when the destination file already exists.

Before replacing the file, Safe CP creates a backup of the old version. If you make a mistake, you can restore the latest overwritten file with one command.

To copy a file, use:

safecp SOURCE DEST

To restore the last overwritten file, use:

safecp undo

You can also see the saved history:

safecp history

When you do not need the backups anymore, you can remove them:

safecp forget

Current Limits

For now, Safe CP only works with regular files. It can undo the last overwrite, but it does not save anything when you copy a file to a new destination.

This is enough for how I use it today. I will probably improve it when I find something missing while using it.

Final Thoughts

I built Safe CP after thinking about how easy it is to overwrite the wrong file with cp. It is a small tool, but having a quick undo option makes the command feel less risky.

The source code and build instructions are available on GitHub.