Writing a text file

I’m trying to build an automated config copy script to copy one router’s current configuration to a backup router automatically. I’m still in the very early stages, but I bumped into a big stumbling block.

How can I write a text file from within a script? For obvious reasons I cannot use a simple /export command and copy that to a backup router (routers will have small but significant differences in their configs), so I wrote a script to build the necessary commands out to the console, but now I need these commands inside a script file which the backup router can fetch and run.

Any ideas?

You can try this method to create a file

#create file
/file print file=myfile
#set file contents
/file set myfile.txt contents="123"

But there is one limitation - you can edit files if the contents is not larger than 4KB