Windows cleverly uses git to realize automatic backup of notes

Today I suddenly discovered that you can use Gitee plus Windows scheduled tasks to realize automatic backup of notes on Windows , multi-terminal synchronization, and historical retrieval . The effect is very good. Let’s introduce it below:

Prepare git repository

Install git: https://git-scm.com/downloads:

image-20230509184611110

Register and log in to gitee, generate the ssh key locally (Baidu for details), and then add it to gitee:

image-20230509184749259

Create a new warehouse:

image-20230509183703940

Fill in the saved folder name as the warehouse name:

image-20230509183749554

Then open a Windows terminal and clone the repository:

git clone [email protected]:13132321/aaaa.git

image-20230509184919374

image-20230509185029871

Configure automatic upload script

After cloning is complete, put your notes into the folder and create a new one 自动上传.bat:

%~d0			
cd %~dp0
git pull
git add ./
git commit -m "Autosave: %date:~0,10% %time:~0,-3%"
git push

timeout /t 3

Double-click to run the test and the upload is successful:

4f77c1db34eb466ea1c0c65ffdd9e1c1

You can see the update just uploaded. The commit content is the upload time:

image-20230522102656020

Set up Windows automatic scheduled tasks

First open the window's task scheduler:

image-20230509190338854

After opening, click once on the red box in the picture below:

Enter the task plan name:

image-20230509190303846

Select the trigger time, with options such as daily, weekly, monthly, etc.:

image-20230509190433444

Select trigger period:

image-20230509190505453

Select a startup program :

image-20230509190627767

Specify the script just now :

image-20230509190648000

Click Finish, and then double-click the newly created scheduled task to adjust the execution cycle :

image-20230509190856731

Finally, right-click to test whether it can be executed. If so, the script will be automatically executed regularly to save the notes :

image-20230509191143817

It can be automatically saved. The automatic save is done:

image-20230509191222356

references

1: window scheduled task_windows scheduled task_wandering worker's blog-CSDN blog

2: Bat script date and time acquisition_bat gets the current time_HMJ_'s blog-CSDN blog



If you have any questions or errors, please feel free to message me privately for corrections.
All rights reserved. Please do not reproduce without authorization!
Copyright © 2023.05 by Mr.Idleman. All rights reserved.


Guess you like

Origin blog.csdn.net/qq_42059060/article/details/130586757