I want to do the following: when a file is changed then the old file should be backed up to another location with different name on Linux. E.g. whenever example.text is changed, at each change, new files should be created like this: example1.text, example2.text ...
There are three good methods to do this:
If you use a GUI text editor such as gedit/pluma and enable the option
Create a backup copy of files before savingin the preferences then your
example1.txtis saved to
example1.txt~upon save. You can enable this for nano with
nano -B example1.txt. Additionally cp with
cp -b example1.txt example2.txtwill create
Use a cron job to backup files in a directory regularly, you can even combine this with a VCS. I can include the script I use if you ask nicely.
Use a VCS directly such as git and commit your files on a local repository (you can even migrate it to a remote location later if you choose) anytime you alter them.
Assuming using ZFS is an option (available either through FUSE or natively on Linux), one way would be to use ZFS automatic snapshots to achieve something close to what you want.
Older snapshots are destroyed so you would need some tuning if you really want to keep each and every file update.